To install Docker on various Linux distributions such as Debian, Ubuntu, CentOS, Fedora, and RHEL, you can follow as root user the distribution-specific instructions outlined below:
Update the apt package index:
apt update
Install packages to allow apt to use a repository over HTTPS:
apt install apt-transport-https ca-certificates curl software-properties-common
Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Set up the stable Docker repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Update the apt package index again:
apt -y update
Install Docker CE (Community Edition):
apt -y install docker-ce
Verify that Docker CE is installed correctly:
docker --version
Install required packages:
yum install -y yum-utils device-mapper-persistent-data lvm2
Set up the Docker repository:
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install Docker CE:
yum install docker-ce
Start Docker:
systemctl start docker
Verify that Docker CE is installed correctly:
docker --version
These instructions should help you install Docker on your desired Linux distribution. After installation, you may need to add your unprivileged user to the docker group to run Docker commands without using sudo.
Note: docker ingress network may conflict with local network settings (i.e. 10.0.0.0/24)
(!) Todo: add commands to set ip address of ingres/bridge network
docker swarm init --listen-addr eth1:2377 --advertise-addr eth1:2377
docker network rm ingress
docker network create --driver overlay --ingress --subnet 10.20.0.0/24 --gateway 10.20.0.1 --scope swarm ingress
docker network inspect ingress
To initialize Docker Swarm mode in a one-node setup, follow these steps:
In a terminal on your Linux machine.
Initialize Docker Swarm by running the following command:
docker swarm init
This command initializes a Swarm on the current Docker engine. It also generates a token that other nodes can use to join the Swarm.
Check Swarm status to ensure it has been initialized successfully:
docker info
Look for the “Swarm: active” line in the output. This confirms that Docker Swarm has been successfully initialized.
docker info | grep Swarm
Here you have successfully initialized Docker Swarm mode on your one-node setup. You can now deploy services and manage them using Docker Swarm commands.