我有以下的 docker-compose
文件
version: '3'
services:
node1:
build: node1
container_name: node1
node2:
build: node2
container_name: node2
这是node1的Dockerfile代码
FROM ubuntu
RUN apt-get update && apt-get install -y iputils-ping
COPY true.sh /var/
CMD ["/var/true.sh"]
node2 Dockerfile扩展了node1, 如下所示
FROM node1
RUN apt-get update && apt-get install -y iputils-ping
COPY true.sh /var/
CMD ["/var/true.sh"]
现在当我使用docker-compose up -d --build
构建镜像时,由于本地镜像仓库为空,我会得到以下错误。
ERROR: Service 'node2' failed to build: pull access denied for node1, repository does not exist or may require 'docker login'
使用Compose构建图像时,我该如何定义标签?目前已经构建了以下图像。
REPOSITORY TAG IMAGE ID CREATED SIZE
docker_node1 latest 52dd5a083162 7 minutes ago 123MB
ubuntu latest 113a43faa138 19 hours ago 81.2MB
我知道我可以使用普通的Docker构建镜像,但我喜欢使用所有必要的配置,以便新手可以使用单个命令引导一个全新的环境,并让同样的命令重新启动更改后的容器,因为更改构建。