title: Docker setup 🐳 date: 2024-05-06T12:43:45+03:00 author: Nicos draft: false tags:

Docker Installation on Linux 🐋

Docker Image

Prerequisites:

  • 64-bit Linux system: Verify using uname -m. If it outputs x86_64 or amd64, 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:

  1. Update package lists:
Bash
sudo apt update  # For Debian/Ubuntu-based systems
sudo yum update  # For Red Hat/CentOS-based systems
  1. 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
  1. 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

  1. 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

  1. 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

  1. 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.

Remember to replace $USER with your actual username in the group membership command.