Docker
Docker installation various depends upon the distribution you use check docker manual
Installing Docker Engine on Debian 11
To install Docker on Debian 11, follow these steps:
Update a Package List
Make sure your package list is up to date by opening a terminal and running the following command.
1
sudo apt update
Install Required Packages
Install the required packages to enable apt to use HTTPS repositories and support other package types.
1
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add Docker Repository
You can add Docker’s official GPG key and repository to your system by following these steps.
1
2
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update Package List Again
Please run the update command again to ensure that the Docker repository is included.
1
sudo apt update
Install Docker Engine
Install Docker Engine and its dependencies.
If you want to keep all the libraries in home directory create the symlink as follows
mkdir /home/.docker/ && ln -s /home/.docker/ /var/lib/docker
1
sudo apt install docker-ce docker-ce-cli containerd.io
If you would like to use the docker compose plugin please add
docker-compose-plugin
Start and Enable Docker
Start the Docker service and enable it to start on boot. First run the command:
1
sudo systemctl start docker
To automatically launch alongside the operating system, include it in the startup configuration with this command.
1
sudo systemctl enable docker
Verify Installation
To ensure that Docker is up and running, try running a basic container with a “Hello World” command.
1
sudo docker run hello-world
Congratulations! You have successfully installed Docker on Debian 11. Get ready to efficiently manage and run containers for your applications.
Enable TCP port 2375 for external connection to Docker
Update the systemd configuration
Locate the docker daemon service file in my case /lib/systemd/system/docker.service
1
2
3
4
5
6
7
8
9
10
11
12
13
❯ systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
Drop-In: /usr/lib/systemd/system/docker.service.d
└─dietpi-simple.conf
Active: active (running) since Wed 2024-03-27 23:10:33 IST; 1 week 2 days ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 1451697 (dockerd)
Tasks: 67
Memory: 48.3M
CPU: 1h 13min 47.364s
CGroup: /system.slice/docker.service
locate the ExecStart and update the tcp lisen port as follows
1
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H=fd:// -H=tcp://0.0.0.0:2375
Reload the systemd daemon:
1
systemctl daemon-reload
Restart docker:
1
systemctl restart docker.service
Verify TCP port
You can verify if the docker is lisening on the port 2375
1
2
❯ ss -lntp | grep 2375
LISTEN 0 4096 *:2375 *:* users:(("dockerd",pid=1451697,fd=3))
Manage Docker as a non-root user
The docker group grants root-level privileges to the user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.
Create the docker
group and add your user:
1
sudo groupadd docker
Add your user to the docker group.
1
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated.
If you’re running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.
You can also run the following command to activate the changes to groups:
1
newgrp docker
Verify that you can run docker commands without sudo.
1
docker run hello-world