How to cretae an Own Docker Image

Posted By : Vishal Dogra | 17-Nov-2015

How to create a Docker image from base image.

 

If you want or think to upload an ISO on docker hub than you can it by some following steps:

 

  1. # apt-get install debootstrap.

  2. # debootstrap  trusty trusty > /dev/null

  3. # tar -C trusty -c . | docker import - trusty

  4. # docker run trusty cat /etc/lsb-release.

 

It will show you the details of your base image.

 

Run the command to execute the docker image trusty.

 

#docker run -i -t trusty /bin/bash

 

Now, just open the new terminal tab and execute the command.

 

# docker ps

 

It will show you the trusty docker image with full details.You have to copy the container id and run with the docker commit to commit the docker image.

# docker commit 560d51aabb94 trusty

 

In my case 560d51aabb94 is the containe ID. you have to replace with yours one.

 

Now, hit docker images on terminal.It will show you the commit snapshot or you can say that an image.

# docker images

 

Copy the image-ID for further process.

 

To push it on docker hub we have to login from comand line by using docker login

 

#docker login

username: vishald

password: *******

Email: abc@example.com

 

To push it on Hub we have to execute some commands.

 

# docker tag 560d51aabb94 vishald/trusty:test

 

test is just the tag name.

 

# docker push 560d51aabb94 vishald/trusty

 

If you want it to test that your docker image which is converted from your base image is working or not.First take a pull from docker hub by using below command.


 

Faced Issues while running the image

 

#docker run -i -t vishald/trusty

 

After execute the above command it gives me the error:-

Unable to find image 'vishald/trusty' locally

Pulling repository vishald/trusty

2015/10/30 16:19:22 Tag latest not found in repository vishald/trusty

If you faced the above error than how we solved it.

 

# docker pull vishald/trusty:test

 

It will download the uploaded docker image and to check that working or not. we need to run the docker image again.

 

#docker run -i -t vishald/trusty:test

 

It will give you the Virtual Machine on your local with root user.



THANKS

 

 

About Author

Author Image
Vishal Dogra

Vishal has been working as a Network Administrator. Vishal's hobbies are playing cards and listening to Sufi songs.

Request for Proposal

Name is required

Comment is required

Sending message..