Docker container inside docker container - how to mount volumes?

37 Views Asked by At

I have a containerA that creates other containers (B, C, D). I'm trying to mount a directory from containers B, C, and D to container A.

How I run containerA

docker run --security-opt="apparmor=unconfined" --cap-add=SYS_PTRACE -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/app -it --rm parentContainer

After containerA is created, it runs a script that creates other containers using

docker run --security-opt=apparmor=unconfined --cap-add=SYS_PTRACE --pid=container:"***" -t -v $(pwd)/contaner_b/logs:/app/logs childContainer

Unfortunately, any files created within child containers are not mounted in the containerA (parent container)

What works is manual docker cp "containerB:/app/logs" /app/container_b/logs" executed in the containerA, but I don't like this approach to be honest. Am I missing something here? Can I make mounts work?

0

There are 0 best solutions below