Docker Compose 不允许使用本地镜像 [英] Docker Compose does not allow to use local images

查看:176
本文介绍了Docker Compose 不允许使用本地镜像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下命令失败,尝试从 Docker Hub 拉取镜像:

$ docker-compose up -d拉取网络服务器(网络服务器:登台)...错误:未找到存储库网络服务器:不存在或没有拉取权限

但我只想使用存在的本地版本的图像:

$ docker 镜像存储库标记图像 ID 创建大小网络服务器暂存 b94573990687 7 小时前 365MB

为什么 Docker 不在本地存储的镜像中搜索?

<小时>

这是我的 Docker Compose 文件:

版本:'3'服务:聊天服务器:图像:聊天服务器:登台端口:- 8110:8110"网络服务器:图像:网络服务器:登台端口:- 80:80"- 443:443"- 8009:8009"- 8443:8443"

和我的 .env 文件:

DOCKER_HOST=tcp://***.***.**.**:2376DOCKER_TLS_VERIFY=真DOCKER_CERT_PATH=/Users/Victor/Documents/Development/projects/.../target/docker

解决方案

一般来说,这应该像您描述的那样工作.试图重现它,但它只是有效...

文件夹结构:

<预><代码>.├── docker-compose.yml└── Dockerfile

Dockerfile 的内容:

来自高山CMD ["echo", "我是 groot"]

构建和标记图像:

docker build -t groot .docker tag groot:最新的 groot:staging

使用 docker-compose.yml:

版本:'3.1'服务:根:图像:groot:分期

并启动docker-compose:

$ docker-compose up正在创建 groot_groot ...创建 groot_groot_1 ... 完成附加到 groot_groot_1groot_1 |我是格鲁特groot_groot_1 退出,代码为 0

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

Why Docker doesn't search among locally stored images?


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"

and my .env file:

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...

Folder structure:

.
├── docker-compose.yml
└── Dockerfile

Content of Dockerfile:

FROM alpine
CMD ["echo", "i am groot"]

Build and tag image:

docker build -t groot .
docker tag groot:latest groot:staging

with docker-compose.yml:

version: '3.1'
services:
  groot:
    image: groot:staging

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 不允许使用本地镜像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆