title: Docker setup 🐳 date: 2024-05-06T12:43:45+03:00 author: Nicos draft: false tags:
Docker Installation on Linux 🐋
Prerequisites:
- 64-bit Linux system: Verify using
uname -m
. If it outputsx86_64
oramd64
, you’re good to go. - Virtualization support: Check if your system supports hardware virtualization technologies like KVM. Refer to your distribution’s documentation for details.
Steps:
- Update package lists:
Bash
sudo apt update # For Debian/Ubuntu-based systems
sudo yum update # For Red Hat/CentOS-based systems
- Install dependencies:
Bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common # For Debian/Ubuntu-based systems
sudo yum groupinstall "Development Tools" # For Red Hat/CentOS-based systems
- Add Docker repository (choose one based on your distribution):
Debian/Ubuntu:
Bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Red Hat/CentOS/Fedora:
Bash
sudo yum install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- Install Docker Engine:
Bash
sudo apt install docker-ce # For Debian/Ubuntu-based systems
sudo yum install docker-ce # For Red Hat/CentOS-based systems
- Start and enable Docker service:
Bash
sudo systemctl start docker # For systemd-based systems (most modern distributions)
sudo service docker start # For older systems using SysV init
sudo systemctl enable docker # To start Docker automatically at boot
- Verify installation:
Run docker run hello-world
to download and execute a simple test image. This should output “Hello from Docker! This message shows that your installation appears to be working correctly.”
Additional considerations:
- Adding your user to the docker group: If you want to run Docker commands without using sudo each time, add your user to the docker group:
Bash
sudo usermod -aG docker $USER
Note: Log out and log back in for the group membership to take effect.
- Docker Desktop: For a graphical user interface for managing Docker, you can install Docker Desktop from https://docs.docker.com/desktop/install/linux-install/.
Remember to replace $USER
with your actual username in the group membership command
.