使用 docker-compose 从私有仓库中拉取镜像 [英] Use docker-compose to pull images from private repository

查看:381
本文介绍了使用 docker-compose 从私有仓库中拉取镜像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 docker-compose 命令来运行多个容器.问题是我的 docker-compose 必须从公共存储库中提取一些图像,从私有存储库中提取一些图像.我打算做的是将所有需要的图像推送到私有存储库,但如何让 docker-compose 从私有存储库中提取图像.

I'm using docker-compose command to run multiple containers. The problem is my docker-compose has to pull some images from the public repository and some from a private repository. What I'm planning to do is push all required images to the private repository but how can I make docker-compose pull the images from the private repository.

简而言之 -> 当图像仅在那里可用时如何指向私有存储库

In short -> How to point to a private repository when the images are only available there

推荐答案

使用 docker login 命令.(官方文档)
输入您的凭据,然后您就可以拉取私有镜像,前提是您拥有访问权限.

Use docker login command. (Official doc)
Enter your credentials, and then you can pull private image, only if you have an access.

如果您想登录到自托管注册表,您可以通过添加服务器名称来指定.

If you want to login to a self-hosted registry you can specify this by adding the server name.

docker login localhost:8080

感谢 @herm's 的评论,如果您想使用 swarm,请使用:--with-registry-auth 选项.Personnaly,我使​​用这个命令:

Thanks to @herm's comment, if you want to use swarm, use : --with-registry-auth option. Personnaly, I use this command :

docker stack deploy --with-registry-auth --compose-file dev.compose.yml myProjectName

这篇关于使用 docker-compose 从私有仓库中拉取镜像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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