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?
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
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.