[英]Building and pushing a docker image from inside a container
Context: I am using repo2docker
to build images containing experiments, then to push them to a private registry. 上下文:我正在使用
repo2docker
构建包含实验的映像,然后将其推送到私有注册表。
I am dockerizing this whole pipeline (cloning the code of the experiment, building the image, pushing it) with docker-compose
. 我dockerizing这整个管道(克隆实验的代码,建筑形象,推)与
docker-compose
。
This is what I tried: 这是我尝试的:
FROM ubuntu:latest
RUN apt-get update && apt-get install -y python3-pip python3-dev git apt-transport-https ca-certificates curl software-properties-common
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
RUN apt-get update && apt-get install docker-ce --yes
RUN service docker start
# more setup
ENTRYPOINT rqworker -c settings image_build_queue
Then I pass the jobs to the rqworker (the rqworker part works well). 然后,我将作业传递给rqworker(rqworker部分运行良好)。
But docker
doesn't start in my container. 但是
docker
不在我的容器中启动。 Therefore I can't login to the registry and can't build the image. 因此,我无法登录到注册表,也无法生成映像。
(Note that I need docker
to run, but I don't need to run containers.) (请注意,我需要运行
docker
,但不需要运行容器。)
解决方案是共享主机的Docker套接字,因此构建实际上发生在主机上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.