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
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
Step 3: Install MySQL inside the Container
You can install the My-SQL client using the following command.
apk add mysql-client
Step 4: Install Firefox
To install Firefox inside the Container, you can use the following command.
apk add 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