本文介绍了Docker Compose不允许使用本地映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下命令失败,尝试从Docker Hub中提取图像:
The following command fails, trying to pull image from the Docker Hub:
$ docker-compose up -d
Pulling web-server (web-server:staging)...
ERROR: repository web-server not found: does not exist or no pull access
但是我只想使用图像的本地版本,该版本存在:
But I just want to use a local version of the image, which exists:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
web-server staging b94573990687 7 hours ago 365MB
为什么Docker不在本地存储的映像中搜索?
Why Docker doesn't search among locally stored images?
这是我的Docker Compose文件:
This is my Docker Compose file:
version: '3'
services:
chat-server:
image: chat-server:staging
ports:
- "8110:8110"
web-server:
image: web-server:staging
ports:
- "80:80"
- "443:443"
- "8009:8009"
- "8443:8443"
和我的。环保文件:
DOCKER_HOST=tcp://***.***.**.**:2376
DOCKER_TLS_VERIFY=true
DOCKER_CERT_PATH=/Users/Victor/Documents/Development/projects/.../target/docker
推荐答案
通常,这应该按照您的描述进行工作。试图重现它,但它确实起作用了……
In general, this should work as you describe it. Tried to reproduce it, but it simply worked...
文件夹结构:
.
├── docker-compose.yml
└── Dockerfile
内容的Dockerfile:
Content of Dockerfile:
FROM alpine
CMD ["echo", "i am groot"]
构建并标记图像:
docker build -t groot .
docker tag groot:latest groot:staging
与docker-compose.yml:
with docker-compose.yml:
version: '3.1'
services:
groot:
image: groot:staging
并启动docker-compose:
and start docker-compose:
$ docker-compose up
Creating groot_groot ...
Creating groot_groot_1 ... done
Attaching to groot_groot_1
groot_1 | i am groot
groot_groot_1 exited with code 0
这篇关于Docker Compose不允许使用本地映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!