[英]can I deploy local build to docker swarm in virtual machine?
I am learning Docker and trying to follow the Docker tutorial and am in step 4 here . 我正在学习Docker并尝试遵循Docker教程,并且在此处的第4步。
Basically in this step, we are creating 2 VMs for docker swarm: 1 as swarm manager and 1 as swarm worker. 基本上,在此步骤中,我们将为docker swarm创建2个VM:1个为swarm管理器,1个为swarm worker。
I think it pulls docker-hub pushed image to the virtual machines to get the service working in swarm. 我认为它会将docker-hub推送的映像拉到虚拟机,以使服务在群中工作。 Problem is I am not pushing my built image to docker hub. 问题是我没有将构建的映像推送到docker hub。
My question is, can I use local build to deploy to the swarm VM? 我的问题是,我可以使用本地构建将其部署到群集VM吗?
I tried to change image
line the example docker-compose.yml
to build
like so: 我试图改变image
线的例子docker-compose.yml
来build
像这样:
version: "3"
services:
web:
# replace username/repo:tag with your name and image details
# image: friendlyhello
build: .
deploy:
replicas: 5
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "4000:80"
networks:
- webnet
networks:
webnet:
it of course does not work, which is why I am asking if there is a way to do this? 它当然不起作用,这就是为什么我问是否有办法做到这一点?
You can create a local registry on the vm or your local machine and push/pull images from local repo 您可以在vm或本地计算机上创建本地注册表,并从本地存储库推/拉映像
docker run -d -p 5000:5000 --restart=always --name registry registry:2
Then name/tag your images using 然后使用命名/标记您的图像
localhost:5000/Image_Name:Tag
Then push images using 然后使用
docker push localhost:5000/Image_Name:Tag
This will let you save your images in a local registry that your swarm can use without pushing to dockerhub 这将使您将图像保存在您的集群可以使用的本地注册表中,而无需推送到dockerhub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.