首页 > 解决方案 > 从容器内部构建和推送 docker 映像

问题描述

上下文:我repo2docker用来构建包含实验的图像,然后将它们推送到私有注册表。

我正在使用docker-compose.

这是我尝试过的:

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

然后我将作业传递给 rqworker(rqworker 部分运行良好)。

docker不会在我的容器中启动。因此我无法登录注册表,也无法构建映像。

(请注意,我需要docker运行,但不需要运行容器。)

标签: dockerdocker-composedocker-in-docker

解决方案


解决方案是共享主机的 Docker 套接字,因此构建实际上发生在主机上。


推荐阅读