Server rental store

Installing Docker on Linux

= Installing Docker on Linux =

This guide provides step-by-step instructions for installing Docker Community Edition (CE) on various Linux distributions and introduces fundamental Docker commands and concepts, including creating a simple Dockerfile. This is an essential skill for modern application deployment and management, especially when leveraging the power of dedicated servers from PowerVPS for your containerized workloads.

Prerequisites

Before you begin, ensure you have: # A Linux server with root or sudo privileges. Dedicated Servers from PowerVPS offer excellent performance and full root access, ideal for running Docker. # A stable internet connection to download packages. # Basic familiarity with the Linux command line. # For this guide, we will cover installation on Debian/Ubuntu and CentOS/RHEL-based systems.

Installing Docker CE

Docker CE can be installed using the official repositories. This is the recommended method as it ensures you receive timely updates.

On Debian/Ubuntu

# Update package lists:
sudo apt update
# Install prerequisite packages: These allow apt to use a repository over HTTPS.
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release
# 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/ubuntu \
  $(lsb_release -cs) stable" sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update package lists again to include the new repository:
sudo apt update
# Install Docker Engine, containerd, and Docker Compose:
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Verify the installation:
sudo docker run hello-world
You should see a message indicating that your installation appears to be working correctly.

On CentOS/RHEL/Fedora

# Uninstall older versions (if any):
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc
# Install required packages:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Add Docker's stable repository:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker Engine, containerd, and Docker Compose:
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Start the Docker daemon:
sudo systemctl start docker
# Enable Docker to start on boot:
sudo systemctl enable docker
# Verify the installation:
sudo docker run hello-world
Similar to Debian/Ubuntu, you should see a confirmation message.

Post-installation Steps

Manage Docker as a non-root user

To run Docker commands without `sudo`, add your user to the `docker` group. # Add user to the docker group:
sudo usermod -aG docker $USER
# Apply the group changes: You will need to log out and log back in, or run:
newgrp docker
Now you can run Docker commands directly:
docker run hello-world

Basic Docker Commands

Here are some fundamental Docker commands to get you started:

Category:Containerization Category:Docker Category:System Administration