[英]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 的新手,正在按照此处找到的文档尝试使用 docker-compose 1.14.0 在 dind 中部署多个容器我得到以下信息
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?我错过了什么?
There is official docker image on dockerhub for docker-compose, just use that. dockerhub上有用于docker-compose的官方 docker镜像,只需使用它即可。
Follow these steps: 跟着这些步骤:
mkdir /root/test
在主机mkdir /root/test
上创建目录 docker-compose.yaml
file with following contents: 使用以下内容创建docker-compose.yaml
文件: version: '2'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
redis:
image: redis
docker run
command to run docker-compose inside the container. 运行docker run
命令以在容器内运行docker-compose。 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. 注意:容器内的/ var / tmp目录中将包含docker-compose.yaml文件,因此我使用-f
选项指定yaml文件的完整路径。 Also docker.sock
is mounted from host onto the container. docker.sock
从主机安装到容器上。
Hope this helps. 希望这可以帮助。
here is a full dockerfile to run docker-compose inside docker这是一个完整的 dockerfile 在 docker 中运行 docker-compose
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
Add docker-compose installation to your Dockerfile before executing docker run. 在执行docker run之前,将docker-compose安装添加到您的Dockerfile中。
For example, if you have an Ubuntu docker, add to your Dockerfile : 例如,如果您有一个Ubuntu码头工人,则将其添加到您的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. 因为看起来好像您的入口点在/ compose文件夹中查找docker compose,而docker-compose默认情况下安装在/ usr / local / bin中。
If you want a concrete docker-compose version (for example 1.20.0-rc2): 如果要使用具体的docker-compose版本(例如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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.