Docker series: 4. Push your Docker image to Hub
This article illustrates how to push or upload your image to the docker hub so that it can be available for download.
root@machine1 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 4c108a37151f 4 weeks ago 64.2MB
centos centos7 9f38484d220f 4 months ago 202MB
centos latest 9f38484d220f 4 months ago 202MB
hello-world latest fce289e99eb9 6 months ago 1.84kB
Run your container and run any script or install packages that are rquired for your image to be part of.
Here, I am trying to create a centos 7 image for any Hadoop node installation with prerequisites setup.
[root@machine1 ~]# docker exec -i -t 45fe220d4030 /bin/bash[root@45fe220d4030 /]# vi presetup.sh
[root@45fe220d4030 /]# chmod +x presetup.sh
[root@45fe220d4030 /]# ./presetup.sh[root@45fe220d4030 mydir]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
As you can see it has installed Java and did other stuff as apart of my Hadoop prerequisites.
[root@45fe220d4030 ~]# java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
[root@45fe220d4030 ~]# exit
Time to commit your image locally.Get your container id using following command.
[root@machine1 ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
45fe220d4030 centos:latest “/bin/bash” 13 hours ago Up 13 hours myoscontainer
commit and list
[root@machine1 ~]# docker commit 45fe220d4030 jacksparrow007/hadooppresetup
sha256:2c3a110c721e9bfbc3d098a1d5082a8bcabdc476d695a067e8be6e8eea6c8441
[root@machine1 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
jacksparrow007/hadooppresetup latest 2c3a110c721e 4 seconds ago 658MB
hadooppresetup 7.6 480bb5e4c896 4 minutes ago 658MB
ubuntu latest 4c108a37151f 4 weeks ago 64.2MB
centos centos7 9f38484d220f 4 months ago 202MB
centos latest 9f38484d220f 4 months ago 202MB
hello-world latest fce289e99eb9 6 months ago 1.84kB
Push your repository to your personal docker hub repo.
[root@machine1 ~]# docker push jacksparrow007/hadooppresetup
The push refers to repository [docker.io/jacksparrow007/hadooppresetup]
6a120d17a342: Pushed
d69483a6face: Pushed
latest: digest: sha256:82ab86d3dbc72440482c85328d99a42cc6304aa27b320d0dff281515b75f82da size: 742
[root@machine1 ~]#
Login to you docker hub and see your image is uploaded over there.
You can use it anywhere now.
Now you are ready to pull this repo.
docker push jacksparrow007/hadooppresetup:tagname
Series next read;
https://medium.com/cloudscoop/cloudscoop-docker-series-remove-docker-image-2150e43fb771