linux - Why can't the container display the content of mounting directory of host? -


i using following command gitlab repository data:

docker run --volumes-from gitlab_data -v $(pwd):/backup genezys/gitlab:7.5.2 tar cvf /backup/gitlab_data.tar /var/opt/gitlab /var/log/gitlab /etc/gitlab  

then extract backup data , run new container check whether data backed successfully:

[root@localhost backup]docker run --name gitlab_data --volume /var/opt/gitlab --volume /var/log/gitlab --volume /etc/gitlab genezys/gitlab:7.5.2 /bin/true [root@localhost backup]# docker run --detach --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data genezys/gitlab:7.5.2 ...... root@19f5c52a95af:/var/opt/gitlab/git-data/repositories/root# ls -alt total 0 drwxrwx---. 2 git git  6 may  8 08:57 . drwxrws---. 3 git git 17 may  8 08:57 ..    

there no content in /var/opt/gitlab/git-data/repositories/root directory.

but actually, can find content on host:

[root@localhost git-data]# cd /var/opt/gitlab/git-data/repositories/root [root@localhost root]# ls -alt total 8 drwxrwx---. 4 polkitd ssh_keys   41 may  8 04:47 . drwxrwx---. 8 polkitd ssh_keys 4096 may  8 04:47 test.git drwxrwx---. 8 polkitd ssh_keys 4096 may  8 04:47 test.wiki.git drwxrws---. 3 polkitd ssh_keys   17 may  8 04:42 .. 

why can't container display content of mounting directory of host?

you not mapping host directories container besides /backup. --volume /var/opt/gitlab creates new volume, if want map directory, use --volume /var/opt/gitlab:/var/opt/gitlab syntax - https://docs.docker.com/reference/run/#volume-shared-filesystems


Comments