I am very new about docker and swarm. I have two virtual server lets say A and B in my local intranet. I configured docker swarm A as manager and B is worker. I have another machine lets say C which has my application's source code and dockerfile. I am able to create docker image successfully and run that image on my machine C. But I don't know how can I pull that image to swarm cluster. Is there anyone to help how can I pull docker image to swarm ?
You need a docker registry, dockerhub
is a good choice if you don't mind your images being public (you can have one private for free).
Otherwise, you can launch your own registry on a machine reachable by machine A and B (could just be A):
docker run -p 5000:5000 --name registry --restart always -d registry:2
Once launched, push your image to it, then in your swarm configuration, specify the image as image.
Recommended reading: https://blog.docker.com/2013/07/how-to-use-your-own-registry/
or you can run the following command on C :
docker build -t my_app .
docker save my_app > myapp.tar
then copy this file to the desired host (B for example) and run
docker load < my_app.tar
The image behaves if it downloaded from a registry ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.