0

Currently i have web application which is running inside docker. This docker container(ContainerA) would dynamically create YAML files based on the input given from UI.

Now, ContainerA would start the containers in the YAML file.

For the shared connection between the host and ContainerA, i am using the following line in volumes.

- /var/run/docker.sock:/var/run/docker.sock.

Now, i am able to run ContainerB(Assuming image in the YAML file). But the configuration files of ContainerB is present on Container A.

When i do a volume mount from ContainerA to ContainerB in YAML file. I get an empty directory.

How to volume mount files from one docker container(container A) into another container(Container B)?

Waseem
  • 69
  • 11
  • You need to mount the same volume into both containers; you can't directly access one container's files from another without doing this. It'd be better still if you can restructure your application to not require file sharing, maybe publishing the configurations via an HTTP POST or over a message bus like RabbitMQ. (And be super careful with the host's Docker socket, since you can use it very easily to root the entire host.) – David Maze Mar 23 '22 at 09:43

1 Answers1

0

if you know your own container name / id you could use docker run --volumes-from <self> ...

Chris Becke
  • 34,244
  • 12
  • 79
  • 148