Skip to content

Docker installation on Linux

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly^[600-developer-docker-docker.md].

Prerequisites

The following installation steps are tailored for Linux systems that utilize the yum package manager (e.g., CentOS, RHEL).^[600-developer-docker-docker.md]

Installation Steps

1. Update System Packages

First, update your installed packages and package cache to ensure you have the latest versions^[600-developer-docker-docker.md].

yum update 

2. Install Docker

Install the Docker package using yum.^[600-developer-docker-docker.md]

yum install -y docker

3. Enable and Start the Docker Daemon

Enable the Docker service to start on boot and then start the service immediately^[600-developer-docker-docker.md].

systemctl enable docker
systemctl start docker

Configuration

Registry Mirrors

To improve download speeds, particularly in regions where the default Docker Hub is slow, you can configure registry mirrors^[600-developer-docker-docker.md].

  1. Edit the daemon configuration file (usually requires root privileges):

    vim /etc/docker/daemon.json
    

  2. Add the registry mirrors to the JSON configuration^[600-developer-docker-docker.md]:

    {
       "registry-mirrors": [
          "https://hub.docker.com/",
          "https://registry.docker-cn.com"
       ]
    }
    

  3. Restart the Docker daemon for changes to take effect (this step is inferred as best practice, though not explicitly stated in the source prose).

Verification

You can verify that Docker is installed correctly by running a test container^[600-developer-docker-docker.md].

docker run hello-world

If the installation is successful, this command downloads a test image and prints a welcome message^[600-developer-docker-docker.md].

You can also check the version information to confirm the client and server are running^[600-developer-docker-docker.md].

docker version

Sources

  • 600-developer-docker-docker.md
  • [[Docker]] (General concept)
  • [[Containerization]]
  • DevOps