create container from docker hub and create docker images from existing container and push docker images on docker hub

How to create container from Docker Hub.
&
How to create Docker images from existing container.
&
How to push Docker images on Docker Hub.

In this article we will see that how to create container from Docker Hub & how to create docker images from existing container & how to push docker images on docker hub. let's start step by step.


How to create container from Docker Hub:

Open browser and open docker hub after that search images what you have to download and make container.



There are two option to create container:

Pull images from docker hub and then create container & Direct use docker run command to create container.

To create container with container name and expose port:
[user@cmp]# docker run -it --name ons -p 80:80 nginx:latest

To start container:
[user@cmp]# docker start ons

Now we are going to run live website, please follow the below step to live nginx server with website.

To create a file which name is index.html by using nano editor tool:
[user@cmp]# nano index.html

After that paste your code in index.html file and then save and exit from nano editor.

To copy index.html file and paste it in nginx directory:
[user@cmp]# docker cp index.html ons:/usr/share/nginx/html/

Open browser and type system ipaddress and port number such as 192.168.1.13:80

How to create images from existing docker container:

If you have existing docker container on your system and you want to make images from docker container so please follow instruction as mention.

To check container name or container id:
[user@cmp]# docker ps



To create images from existing docker container:
[user@cmp]# docker commit ons saiyyadhussain/nginx:v1

Notes:
ons:  It is container name you can use container id or container name.

saiyyadhussain/nginx :  It is account name on Docker Hub and images name also when you commit any container to create images. It is need when you push images on dockerhub for repository.
v1: It’s tag name.

To check images:
[user@cmp]# docker images

How to push docker images on Docker Hub:

If you have docker images on your local system and you want to push docker images on docker hub so please follow instruction as mention.

To check images:
[user@cmp]# docker images

To docker hub login on local system:
[user@cmp]# docker login
Note: It will ask for user id and password of docker hub.



To push docker images on docker hub:
[user@cmp]# docker push saiyyadhussain/nginx:v1

After completing pushing task you can check your images on docker hub.


Share:

0 comments

Please leave your comments...... Thanks