从容器内部构建和推送 docker 图像
Building and pushing a docker image from inside a container
上下文:我正在使用 repo2docker
构建包含实验的图像,然后将它们推送到私有注册表。
我正在用 docker-compose
对整个管道进行 docker 化(克隆实验代码、构建图像、推送它)。
这是我试过的:
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
到 运行,但我不需要 运行 个容器。)
解决方案是共享主机的 Docker 套接字,因此构建实际上发生在主机上。
上下文:我正在使用 repo2docker
构建包含实验的图像,然后将它们推送到私有注册表。
我正在用 docker-compose
对整个管道进行 docker 化(克隆实验代码、构建图像、推送它)。
这是我试过的:
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
到 运行,但我不需要 运行 个容器。)
解决方案是共享主机的 Docker 套接字,因此构建实际上发生在主机上。