Docker Compose不允许使用本地图像
以下命令失败,尝试从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
但我只想使用图像的本地版本,它存在:
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE web-server staging b94573990687 7 hours ago 365MB
为什么Docker不在本地存储的图像中search?
这是我的Docker撰写文件:
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"
和我的.env文件:
DOCKER_HOST=tcp://***.***.**.**:2376 DOCKER_TLS_VERIFY=true DOCKER_CERT_PATH=/Users/Victor/Documents/Development/projects/.../target/docker
一般来说,这应该像你描述的那样工作。 试图重现它,但它只是工作…
文件夹结构:
. ├── docker-compose.yml └── Dockerfile
Dockerfile的内容:
FROM alpine CMD ["echo", "i am groot"]
构build和标记图像:
docker build -t groot . docker tag groot:latest groot:staging
用docker-compose.yml:
version: '3.1' services: groot: image: groot:staging
并启动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.yml中,你可以指定build: .
:。 而不是build: <username>/repo>
为本地构build(而不是从docker-hub拉出) – 我无法validation这一点,但我相信你可能能够为docker-compose做多个服务的相对path文件。
services: app: build: .
参考: https : //github.com/gvilarino/docker-workshop
您可能需要更改您的图片标记以使用斜杠/
分隔两个部分。 所以,而不是
chat-server:staging
做一些事情:
victor-dombrovsky/chat-server:staging
我认为Docker标签背后有一些逻辑,“一部分”标签被解释为来自DockerHub的官方图像。