1

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 ?

Alper Gunay
  • 83
  • 2
  • 5

2 Answers2

2

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://www.docker.com/blog/how-to-use-your-own-registry/

Lee
  • 29,398
  • 28
  • 117
  • 170
Siyu
  • 11,187
  • 4
  • 43
  • 55
0

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 ;)