Why does docker prompt “Permission denied” when backing up the data volume?

后端 未结 1 1931
伪装坚强ぢ
伪装坚强ぢ 2021-01-13 17:28

I am following the docker document to test the backup process of data volumes.

The following 2 steps are all OK:

docker create -v /dbdata --name          


        
相关标签:
1条回答
  • 2021-01-13 18:15

    I just tried the commands you listed and they worked for me, both under an OSX platform and also a straight up linux platform. The thing is you are mounting $(pwd) (from your host) to /backup (in the ubuntu image, third docker run above).

    I suspect that when you launch the command you are in a directory that is not writable? I tried to get it to fail like this:

    mkdir failme
    chmod 000 failme
    cd failme
    docker run --volumes-from dbdata -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata
    

    But, it worked :-)

    So, I cd'ed into a directory that isn't writable by root:

    cd /proc
    root@kube:/proc# docker run --volumes-from dbdata -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata
    tar: /backup/backup.tar: Cannot open: Permission denied
    tar: Error is not recoverable: exiting now
    

    Is it possible that you are starting from a directory that is not writable by root?

    Please post the output to these commands: First, run:

    docker run --name ins --volumes-from dbdata -v $(pwd):/backup ubuntu sleep 99999 &
    

    (instead of the backup command command you have listed.)

    then do an inspect and post those results:

    docker inspect ins
    

    And the answer turned out to be that it was the selinux causing the errors. The Original Poster found the answer:

    setenforce 0
    
    0 讨论(0)
提交回复
热议问题