2 min read

Setting Up Docker on Various Linux Distributions for Website Deployment

Setting Up Docker on Various Linux Distributions for Website Deployment
Photo by Rubaitul Azad / Unsplash

Introduction:

Docker is a powerful containerization platform that allows you to package and distribute applications along with their dependencies in a lightweight, portable container. This guide will walk you through the process of setting up Docker on different Linux distributions to facilitate the deployment of your website.

  1. Ubuntu:
    • Update the package list: sudo apt update
    • Install necessary packages: sudo apt install apt-transport-https ca-certificates curl software-properties-common
    • Add Docker's 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 [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    • Install Docker: sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io
    • Add your user to the docker group: sudo usermod -aG docker $USER
    • Start the Docker service: sudo systemctl start docker
  2. CentOS:
    • Enable the Docker CE repository: sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
    • Install Docker: sudo dnf install docker-ce docker-ce-cli containerd.io
    • Start and enable the Docker service: sudo systemctl start docker && sudo systemctl enable docker
  3. Fedora:
    • Install Docker: sudo dnf install docker
    • Start and enable the Docker service: sudo systemctl start docker && sudo systemctl enable docker
  4. Debian:
    • Update the package list: sudo apt update
    • Install necessary packages: sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release
    • Add Docker's GPG key: curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
    • Set up the stable Docker repository: echo "deb [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
    • Install Docker: sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io
    • Add your user to the docker group: sudo usermod -aG docker $USER
    • Start the Docker service: sudo systemctl start docker

Conclusion:

Setting up Docker on various Linux distributions involves a few common steps, such as adding the Docker repository, installing the Docker package, and starting the Docker service. By following these distribution-specific instructions, you can ensure a smooth setup process for deploying your website using Docker containers.