Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker compose inside docker in a docker

I am pretty new to docker and was following the documentation found here, trying deploy several containers inside dind using docker-compose 1.14.0 I get the following

docker run -v /home/dudarev/compose/:/compose/ --privileged docker:dind /compose/docker-compose
/usr/local/bin/dockerd-entrypoint.sh: exec: line 21: /compose/docker-compose: not found

Did I miss something?

like image 223
Ruso_x Avatar asked Dec 04 '22 22:12

Ruso_x


1 Answers

There is official docker image on dockerhub for docker-compose, just use that.

Follow these steps:

  • Create a directory on host mkdir /root/test
  • Create docker-compose.yaml file with following contents:
version: '2'

services:
  web:
    build: .
    ports:
     - "5000:5000"
    volumes:
     - .:/code
  redis:
    image: redis
  • Run docker run command to run docker-compose inside the container.
docker run -itd -v /var/run/docker.sock:/var/run/docker.sock -v /root/test/:/var/tmp/ docker/compose:1.24.1  -f /var/tmp/docker-compose.yaml up -d

NOTE: Here /var/tmp directory inside the container will contain docker-compose.yaml file so I have used -f option to specify complete path of the yaml file. Also docker.sock is mounted from host onto the container.

Hope this helps.

like image 69
mchawre Avatar answered Jan 07 '23 12:01

mchawre