Setting the container volume in another container on a different path

Can I install a volume from a container to another container on a different path? For instance.

  • contA expands the scope of /source
  • installing it in another docker run --volumes-from contA -v /source/somedir:/etc/otherdir container docker run --volumes-from contA -v /source/somedir:/etc/otherdir

I am trying to use this with docker-compose and jwilder/nginx-proxy :

Docker-compose.yml

 myapp: build: . command: ./run.sh volumes: - /source nginx: image: jwilder/nginx-proxy volumes_from: - myapp volumes: - /source/vhost.d:/etc/nginx/vhost.d:ro - /var/run/docker.sock:/tmp/docker.sock links: - myapp:myapp 

If I try so hard, I don't see the files in /etc/nginx/vhost.d :

 $ docker-compose run nginx bash root@f200c1c476c7 :/app# ls -l total 32 -rw-r--r-- 1 root root 1076 Apr 9 22:10 Dockerfile -rw-r--r-- 1 root root 1079 Apr 9 22:10 LICENSE -rw-r--r-- 1 root root 129 Apr 9 22:10 Procfile -rw-r--r-- 1 root root 8385 Apr 9 22:10 README.md -rw-r--r-- 1 root root 5493 Apr 9 22:10 nginx.tmpl root@f200c1c476c7 :/app# ls -l /etc/nginx/vhost.d total 0 root@f200c1c476c7 :/app# ls -l /source/nginx/ total 8 -rw-r--r-- 1 1000 staff 957 Apr 24 07:17 dockerhost.me 
+6
source share
1 answer

This is not possible, given that the syntax - v /host/path:/container/path reserved for setting the path from the host (and not from another container)

This allows you to add a symbolic link in the second container from /etc/otherdir to /source/somedir (which will exist due to the --volumes-from contA )

+1
source

Source: https://habr.com/ru/post/985856/


All Articles