Dockerfile install docker command

Docker provides a simple way to configure any docker image and create your own custom image with the help of the dockerfile.

Apart from Docker Commit we can build the Docker images using “Dockerfile“. Dockerfile is a text file or a script which contains Keywords and set of Linux commands which are executed automatically whenever we build the Docker Image. Creating Docker images using Docker file is similar to template concept of Virtualization world. If you have Jupyter Notebook in your docker container, you can install any python package by running a new Terminal in Jupyter by clicking the button shown here: and running: pip install The package stays in the docker container even after you exit the container.

Dockerfile Alpine Install Docker

Aug 05, 2020 Install Docker and Learn Docker Container Manipulation – Part 1; Deploy and Run Applications under Docker Containers – Part 2; Basically, a Docker file contains various instructions in order to build and configure a specific container based on your requirements. The following instructions are the most used, some of them being mandatory. Apt-get install -y libboost-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev libboost-math-dev libboost-test-dev libboost-python-dev libboost-filesystem-dev zlib1g-dev && # b/182601974: ssh client was removed from the base image but is required for packages such as stable-baselines.

In this tutorial, you will learn how to pull an official image from the Docker repository and customize it according to your own requirements. And then you can run and verify the custom docker image.

Creating custom docker image

Docker Dockerfile Install Python

So, in this example, you’ll be using an Alpine Linux image that does not include the Vim editor by default. You’ll modify this image to create a new docker image of Alpine Linux that includes Vim editor by default. It cannot get any simpler than this. can it?


If you have not already, please install Docker on Ubuntu or whichever Linux distribution you are using. Make sure to add yourself to the docker group so that you can run docker without sudo.
You’ll need active internet connection for downloading the base docker image.

Step 1: Get docker image [optional]

I chose Alpine Linux in this example because it is really small. The Alpine docker image is hardly 5 MB in size, can you believe it? It’s the perfect Linux distribution for containerization.

This step is optional. I included it show that you can compare it with the customized docker image.

Pull the latest docker image of Alpine Linux using docker pull command:

Step 2: Create Dockerfile with the needed customization

Now let’s create a new empty file named Dockerfile using touch command.

Dockerfile Apt-get Install Docker

Now you need to edit this file and these three lines to it and save it. You can use an edition like Vim or Nano or use cat command to add these lines to the Dockerfile.

What you are doing here is to create a new docker image by downloading the latest Alpine docker image from the Docker Hub.

Like apt, Alpine uses apk package manager. So the next two commands are basically telling Alpine linux to update the available package cache (apk update) and then install Vim (apk add vim).

As you can see, with RUN in Dockerfile, you can customize your base docker image by running specific commands.

Step 3: Create the custom docker image with Dockerfile

The command to build the custom image from the Dockerfile looks like this:

With the -t tag, you specify the name of your custom docker image.

Considering that your Dockerfile is in your current directory, you can create the new docker image of Alpine Linux with Vim installed like this:

Dockerfile Install Docker Client

Let’s see the available Docker images on the system now:

You can see that the base docker image which was hardly 5 MB in size is now 33 MB with Vim installed on it (and the package cache updated).

Now, let’s verify that your modified docker images has vim installed by running a container from it:

Ableton live suite mac torrent. Once you are inside the container, you can verify that Vim is installed by checking its version:

Dockerfile Install Docker Cli

Exit the container by typing exit in the terminal. Stop the container, remove the container and remove the docker images (if you want to) to free up disk space.

Congrats! You just learned how to create your very own customized docker image.

I know it’s not a very extensive tutorial and you may have complex need. But this tutorial works as the first step towards understanding docker image customization.

I highly recommend reading more on Dockerfile to know what other options you have available for customizing docker images.

If you have questions or suggestions, please leave a comment below.

Become a Member for FREE
Become a member to get the regular Linux newsletter (2-4 times a month) and access member-only contents.

Join the conversation.

Coments are closed
Scroll to top