Docker Hub is a cloud-based library and community for container images, where we can find official images like Nginx, MongoDB, PostgreSQL, etc. Docker Hub seamlessly ships any application anywhere. So that we have to build the docker image and push it to the Docker registry and it will be available for anybody if you make it public.
But if the requirement is to keep the docker image private, so that it could only be shared with a specific group or team, that is also feasible. We can collaborate and build with our team, create and manage users and grant access to our repository and automate deployment with the production pipeline.
The ability to share container images on the Docker hub registry allows users to quickly share and build images. In this write-up, we will see how to use this feature.
Create an AMI Docker AWS EC2 instance
login into the EC2 instance
$ sudo su
# yum update -y
To configure docker we need to install the docker package
# yum install docker docker-distribution -y
To start the docker engine
# service docker start
To run a pre-existing docker image
# docker run -it ubuntu
:/# ls
Create a file
:/# touch myproject
:/#exit
To list docker images
# docker images
To list details of running containers like ID, name, image
# docker ps -a
To create an image of a container
# docker commit NAME New_image_name
To push images to Docker Hub we should have an account in Docker Hub. To signup in Docker Hub
Link is
https://hub.docker.com/
Docker_ID: username
email:-
password:-
To login into docker hub
# docker login --> username --> password
To tag the docker image and push the image to the docker hub we have to specify the docker hub username to
Upload image to the specific repository under docker hub user.
# docker tag New_image_name
username/project_name
To share a local docker image to docker hub
# docker push username/project_name
The registry has several repositories and a repository has many different versions of the same image which are individually tagged.
To permit acces to specific team on repository –> click on image –> setting –> make private –> name
Create another EC2 instance
$ sudo su
# yum update && yum install docker -y && service docker start
# docker images
To login into docker hub
# docker login --> username --> password
To pull image from docker hub
# docker pull username/project_name
# docker images
To create a container using image
# docker run -it –name container_name username/project_name binbash
:/# ls
:/# exit
To delete images
# docker rmi -f $(docker image -q)
# docker images
Why use Docker Hub?
- Features that enable continuous integration and continuous delivery.
- Docker hub supports GitHub, automated tests, and webhooks.
- Currently, docker hub offers unlimited public repositories and one private repository with up to 3 collaborations.
- A plethora of docker certified and verified official pre-built images exists in docker hub public registry.
Finding it difficult? Contact our DevOps support team.