10

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?

3
  • 1
    You need to install docker-compose command in your container. It doesn't come with compose by default Commented Jul 1, 2017 at 1:29
  • If you are new to docker, let me first ask you if you are certain you want a docker-in-docker setup? Check this blog post (specifically "the solution" part). Commented Jul 5, 2017 at 15:03
  • @JonesV yes, dind is a must, it is used to build and test images and keep the host docker clean, nevertheless the one which is hosted on docker hub is based on busybox and for some reason it seems not to be able to find the binary, but if you build the image from original repo, as it has a proper bash (not ash like in busybox) it find it. I must be something to do with how busybox mounts the filesystem and I am quite confused here. Commented Jul 6, 2017 at 8:58

3 Answers 3

16

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.

Sign up to request clarification or add additional context in comments.

Comments

5

Add docker-compose installation to your Dockerfile before executing docker run.

For example, if you have an Ubuntu docker, add to your Dockerfile:

RUN aptitude -y install docker-compose
RUN ln -s /usr/local/bin/docker-compose /compose/docker-compose

Because it looks like if your entry-point looks up docker compose in /compose folder, while docker-compose is installed in /usr/local/bin by default.

If you want a concrete docker-compose version (for example 1.20.0-rc2):

RUN curl -L https://github.com/docker/compose/releases/download/1.20.0-rc2/docker-compose-`uname -s`-`uname -m` -o /compose/docker-compose
RUN chmod +x /compose/docker-compose

1 Comment

Had to use the following to get the install working: RUN curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose RUN chmod +x /usr/local/bin/docker-compose
5

here is a full dockerfile to run docker-compose inside docker

FROM ubuntu:21.04
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y python3
RUN apt-get install -y pip
RUN apt-get install -y curl
RUN curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
RUN chmod +x /usr/local/bin/docker-compose

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.