Ensure that you have account in docker hub (hub.docker.com). To verify it, you can do web login and on successful login, you will see the homepage with your login info.
Ensure that you have created a repository. In above screenshot, testexample is the repository name. If not, create repository via the docker GUI. In your repository, you will see the command to pull the image.
You will see your created public repo in the search of hub.docker.com
For example, I have here tagged ubuntu image for my repository.
Create image for push
[root@ubuntu ~]# docker pull ubuntu:14.04
14.04: Pulling from library/ubuntu
bae382666908: Pull complete
29ede3c02ff2: Pull complete
da4e69f33106: Pull complete
8d43e5f5d27f: Pull complete
b0de1abb17d6: Pull complete
Digest: sha256:6e3e3f3c5c36a91ba17ea002f63e5607ed6a8c8e5fbbddb31ad3e15638b51ebc
[root@ubuntu ~]# docker images | grep ubuntu
ubuntu 14.04 132b7427a3b4 4 months ago 188 MB
ubuntu latest f7b3f317ec73 5 months ago 117.3 MB
[root@ubuntu ~]# docker tag ubuntu:14.04 dpkumar/testexample:latest
[root@ubuntu ~]# docker images | grep dpkumar/testexample
dpkumar/testexample latest 132b7427a3b4 4 months ago 188 MB
Note that here image name is same as my repo name (dpkumar/testexample).
You need to push image to this repository. Or else, you will get error while trying to pull image (as shown below)
Error while pulling image
[root@ubuntu ~]# docker pull dpkumar/testexample
Using default tag: latest
Please login prior to pull:
Username (dpkumar):
Password:
Pulling repository docker.io/dpkumar/testexample
Tag latest not found in repository docker.io/dpkumar/testexampleErro
Use the docker client to push image. Ensure that you are logged in to to your account.
Login to my account
[root@ubuntu ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (dpkumar):
Password:
Login Succeeded
Push image
[root@ubuntu ~]# docker tag testexample docker.io/dpkumar/testexample
[root@ubuntu ~]# docker push docker.io/dpkumar/testexample:latest
The push refers to a repository [docker.io/dpkumar/testexample]
7bf04ad1d006: Pushed
023b7696bd58: Pushed
ad37eb38337a: Pushed
350bf4dddc59: Pushed
554f627f09ee: Pushed
latest: digest: sha256:35003d52ec1757cb5c51123bf10486e345b31023a28d9adbaf2887d9de1f8e49 size: 1359
In the web UI, you will see this upload info
Pull image
root@ubuntu:~# docker pull dpkumar/testexample:latest
latest: Pulling from dpkumar/testexample
39a58acf9d5e: Pull complete
394f40b6e203: Pull complete
56fc1816560a: Pull complete
5f2f185e265b: Pull complete
3f66fe0f18c9: Pull complete
57f332e77ce4: Pull complete
Digest: sha256:6c54ef212b2058596bfa2ad083aaa2c73d22e03dff046fa66f6ee4f0cab0a971
Status: Downloaded newer image for dpkumar/testexample:latest
root@ubuntu:~# docker images | grep dpkumar
dpkumar/testexample latest 57f332e77ce4 4 months ago 188 MB
Note that if your repo is private, you need to login before pulling image
You can verify that image is proper.
Image verification
root@ubuntu:~# docker run -dt -name testdp dpkumar/testexample:latest
Warning: '-name' is deprecated, it will be replaced by '--name' soon. See usage.
a6a62ccf918b0e8264ca213fc67c98709a3608d6e300263ce2fdd8b53772bec5
root@ubuntu:~# docker exec -it testdp bash
root@a6a62ccf918b:/# ps ax
PID TTY STAT TIME COMMAND
1 ? Ss+ 0:00 /bin/bash
19 ? Ss 0:00 bash
34 ? R+ 0:00 ps ax
root@a6a62ccf918b:/# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
https://askubuntu.com/questions/688844/how-to-push-an-image-to-docker-hub
https://hub.docker.com/r/dpkumar/testexample/