Docker Community Forums

Share and learn in the Docker community.

Volumes in nested containers?

Hello, I am new to docker. I have a gitlab pipeline using a docker container as the runner. In that container, I use docker compose to bring up several nested containers. I want each of the nested containers to have a volume but, when I add the syntax to create the volume. All the containers die after starting. Is it possible to have volumes in the nested containers within the gitlab pipeline?

# docker -v

Docker version 20.10.3, build 48d30b5

# docker-compose -v

docker-compose version 1.28.6, build 5db8d86f

# uname -a

Linux bef20edf896a 5.4.0-70-generic #78~18.04.1-Ubuntu SMP Sat Mar 20 14:10:07 UTC 2021 x86_64 GNU/Linux

version: '3'

networks:

mynetwork:

ipam:

config:

- subnet: 172.20.0.0/24

services:

cdn.p:

restart: always

# image: node:6.9.2

image: mock-p:0.1

build: mock-p

volumes:

- ./mock-p:/var/mock-p

working_dir: /var/mock-p

command: ["node", "server.js"]

networks:

mynetwork:

ipv4_address: 172.20.0.11

cloud:

restart: always

# image: node:6.9.2

image: mock-appd:0.1

build: .

volumes:

- .:/var/mock-appd

working_dir: /var/mock-appd

command: ["node", "serve-appd.js"]

networks:

mynetwork:

ipv4_address: 172.20.0.12

viss:

restart: always

# image: node:8-alpine

volumes:

- ./viss:/var/viss

image: viss:0.1

build: viss

working_dir: /var/viss

command: ["npm", "start"]

ports:

- "7080:7080"

cmock:

restart: always

image: cmock-api:0.1

build: cmock-api

volumes:

- ./cmock-api:/var/cmock-api

working_dir: /var/cmock-api

command: ["node", "index.js"]

ports:

- 11000:11000

data-server:

restart: always

# image: node:6.9.2

volumes:

- ./dummy-json-server:/var/dummy-json-server

image: dummy-json-server:0.1

build: dummy-json-server

command: ["node", "app.js"]

ports:

- 8080:8080

I'm seeing Errors like:

cloud_1 | Error: Cannot find module '/var/mock-appd/serve-appd.js'

Docker does not support relative paths for mount points inside the container. Multiple containers can use the same volume in the same time period. … If you specify a volume name already in use on the current driver, Docker assumes you want to re-use the existing volume and does not return an error.