Would you like to learn how to install docker on Linux and create a custom Ubuntu Linux image? In this tutorial, we are going to show you how to install docker on Linux and how to use it to create a custom image of Ubuntu.

Hardware List:

The following section presents the list of equipment used to create this Ubuntu Linux tutorial.

Every piece of hardware listed above can be found at Amazon website.

Ubuntu Playlist:

On this page, we offer quick access to a list of videos related to Ubuntu Linux.

Don’t forget to subscribe to our youtube channel named FKIT.

Ubuntu Related Tutorial:

On this page, we offer quick access to a list of tutorials related to Ubuntu linux.

Tutorial – Docker on Linux

On the Linux console, use the following commands to install Docker.

# apt-get update
# apt-get install docker.io

Download the Ubuntu docker image from the online repository.

# docker pull ubuntu

List the Docker images installed on your system.

# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest f975c5035748 5 days ago 112 MB

Start a new Linux docker container using the Ubuntu image downloaded.

# docker run -it ubuntu bash

In our example, the Ubuntu image was used to start a new interactive Ubuntu container.

We are also accessing the console of the new Ubuntu to make the desired modifications.

Let’s install the VIM editor on the new Ubutu linux container.

# apt-get update
# apt-get install vim

Now, we need to get out of the Linux container and list the containers that we have available in our computer.

# exit
# docker container ls -a

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
16a90215465a ubuntu “bash” 5 minutes ago Exited (0) 6 seconds ago vigilant_austin

Use the following command to create a new docker image from a custom Linux container.

# docker commit 16a90215465a my-linux
# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
my-linux latest 277f6da903ae 23 seconds ago 210 MB
ubuntu latest f975c5035748 5 days ago 112 MB

We created a custom Ubuntu Linux docker image which has the application vim installed by default.

To start a new Docker container using our custom image, use the following command.

# docker run -it my-linux bash