Docker Part -4 (Docker hub and docker volume )

In this Part we usually discuss about what about →

Aakib
4 min readOct 7, 2023
  1. Docker hub
  2. Docker Volume

what is Dockerhub →

As you are now a devops engineer you must knew about github that is centrilised placed for all written codes docker hub is similiar to github docker hub is centrilised location for imges

There is no. of latest images of Ubuntu ,python,busybox ,httpd etc… are present which you could fetch by command

  1. Docker search <image name>
  2. Docker pull <image name>

and you are also able to push your customized image to docker hub which you can use later for various purpose

Steps to push image to docker hub →

  1. First you need to have an account on dockerhub just sign up and create your account
this is what dockerhub front page looks like

2. you need to create a public repo which you could use to push images

go to repositories option → click on create repo

3. now back to your terminal and pull any of the image let’s say ubuntu by command

Docker pull ubuntu

4. Now create a container from image

docker run -it — name aakib ubuntu /bin/bash

now you are inside a container make a file changes by →cat > changes and then exit from container

5. Now create image of existing container by command →

docker commit <container id> <image name >

6. Now login to docker hub →docker login

If you login Successfully you have a message login succeed

7. Before you can push an image to Docker Hub, you need to tag it with your Docker Hub username and the desired repository name.

docker tag local-image-name username/repository:tag

local-image-name= image name

username =dockerhub username

tag = what you want to be

and then push your image to dockerhub by command

docker push username/repository:tag

8. verify it by going to your dockerhub and select the repo where you psuhed the image

This is all about dockerhub let’s move to docker volumes

What is Docker Volumes →

  1. Volume is simply a directory inside our container
  2. First we have to declared this directory as a volume and then share volume
  3. Even if we stop container still we can access volume
  4. Volume will be created in one container
  5. You can declare a directory as a volume while creating container
  6. You can’t create volume from existing container
  7. You can share volume to any number of container
  8. Volume will not be included venue update an image
  9. You can mapped volume in two ways
  10. Container to container
    2. Host to container

Benefits of volume →

  1. Decoupling container from storage → Even if we delete a container with a connected volume, the volume continues to exist independently, storing our data safely.
  2. Share volume among different containers
  3. Attach volume to multiple containers
  4. On deleting container volume does not delete

Create Volume from dockerfile

vim dockerfile and write the above content

create an image of your dockerfile by above command

now run a container of your image and go inside to your container

by running ls you could see a directory called my volume

--

--

Aakib
Aakib

Written by Aakib

Cloud computing and DevOps Engineer and to be as a fresher I am learning and gaining experiance by doing some hands on projects on DevOps and in AWS OR GCP

No responses yet