
This assumes you have installed Docker on Linux and Docker is running.
A Docker image contains the code used to create a Docker container, such as creating a Nginx web server, or a mySQL server, or a home grown app, and the list goes on. In this way, an image is like a template used to create a container. An image is kind of like a virtual machine, but much more light weight, using significantly less storage a memory (containers are usually megabytes in size).
Let's say you have an image named hello-world that you want to push to Docker Hub.
~]$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 1120808b5d7a 2 minutes ago 231MB
On Docker Hub (https://hub.docker.com), create a repository. In this example, the name of my repository is jeremycanfield/hello-world.
In this scenario, I would need to tag the image as <image name or ID> jeremycanfield/<name>:<version>.
sudo docker tag hello-world jeremycanfield/hello-world:latest
sudo docker login --username jeremycanfield docker.io
And then use the docker push command to push the image to Docker Hub.
~]$ sudo docker push jeremycanfield/hello-world:latest
The push refers to repository [docker.io/jeremycanfield/hello-world]
74ddd0ec08fa: Pushed
latest: digest: sha256:62be80244f61883cbdd35d5d81a273946e94ab48f7b4cd446fbe1974bc5e0149 size: 529
Now the image should be on Docker Hub.
Did you find this article helpful?
If so, consider buying me a coffee over at