How to Install Docker on Alpine Linux

As you known Docker is a containerization platform that allows you to deploy and manage applications within lightweight containers.

Alpine Linux is a minimalistic and secure Linux distribution, making it an excellent choice for running Docker containers. From my experience, OS needs
at least 256Mb plus additional RAM for your applications.

In this guide, I'll show how installing Docker on Alpine Linux in few simple commands.

Prerequisites

Before we start, ensure you have the following:

  1. A running Alpine Linux system.
  2. Administrative (root) access or a user account with sudo privileges.

Here you can read How to install Alpine Linux in Proxmox

If you login as root user just execute all commands below without modification. But if you login as a different user add sudo before each command.

1. Update Package Repository

It's a good practice to start by updating the package repository to ensure you have the latest package information.

apk update

This command fetches the latest package information from the Alpine repository.

2. Install Docker

Alpine Linux provides Docker packages in its community repository, so you need to check this repository uncommented in file /etc/apk/repositories and then run apk update. Now run the following command:

apk add docker

This command installs the Docker package and its dependencies.

3. Start and Enable Docker Service

Let's allow Docker service starts automatically on system boot and start this server now:

rc-update add docker boot
service docker start

4. Verify Docker Installation

To confirm that Docker is successfully installed and running, execute these commands:

docker version
docker info

These commands should display the Docker version information and various details about your Docker installation.

5. Run a Test Container

Now let's start a simple container.

docker run -it --rm ubuntu

This command will start an interactive session within an Ubuntu Linux container. You can exit the container by typing exit.

Check Docker version and start Ubuntu Linux container

6. Add user to docker group

By default, Docker requires root privileges to run commands. To avoid using sudo every time you want to use Docker, you can add your user to the Docker group. To add user1 to docker group execute this commands:

addgroup docker
adduser user1 docker

For apply changes, you need to logout and then login as user1. After that, you should be able to run Docker commands without using sudo.