Open In App

Creating an Alpine Docker Container

Last Updated : 31 Oct, 2020
Like Article

Alpine is a Linux Distribution. Docker provides you with the low sized (only 5 MB) Alpine Linux Image. The Alpine Linux Docker Image has advantages over the Ubuntu Image because of its relatively lower size and it provides almost all the functionalities that an Ubuntu Image can. In this article, we will see how to build an Alpine Linux Image. We will try to install MySQL client, Python 3, and Firefox inside the Alpine Linux Docker Container as well.

To create the Alpine Docker Container follow the below steps:

Step 1: Pull and Run the Alpine Image

To run the Alpine Image Docker Container, you can use the Docker run command.

sudo docker run -it alpine:3

Running the Alpine Container

Running the Alpine Container

Once the Image is loaded, it opens up the shell for you automatically.

Step 2: Install Python 3 

To install python 3 inside the Alpine Container, you can use the apk add command inside the shell.

apk add python3 

Installing Python 3

Installing Python 3

Step 3: Install MySQL inside the Container

You can install the My-SQL client using the following command.

apk add mysql-client

My-SQL Client

My-SQL Client

Step 4: Install Firefox

To install Firefox inside the Container, you can use the following command.

apk add firefox

Installing Firefox

Installing Firefox

Step 5: Commit the changes in the Image

You need the Container Id to commit the changes in the Image.

To find the Container ID, use this command.

sudo docker ps -a

Copy the Container ID and paste it in this command.

sudo docker commit eacdf78d1bde my-alpine

“my-alpine” is the new image name.

You can verify by listing the images.

sudo docker images 

Docker commit

Docker commit

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads