Install Docker Engine under Centos7

  • 2020-06-01 11:19:25
  • OfStack

1. Prerequisites

The preferred requirement is a 64-bit operating system and a 3.10 or later kernel.

View the current kernel version:


$ uname -r
3.10.0-229.el7.x86_64

2.yum install Docker Engine

There are two ways to install Docker Engine, we first select the yum installation, and Docker officially provides the yum source.

1. Log in to your server using regular sudo or root, update yum, and make sure your software is up to date


$ sudo yum update

2. Add the yum source for Docker


$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

3. Install the Docker package


$ sudo yum install docker-engine

4. Set the startup of Docker service


$ sudo systemctl enable docker.service

5. Start the Docker service


$ sudo systemctl start docker

6. Verify that Docker has been installed successfully


$ sudo docker run --rm hello-world

3. The script installs Docker Engine

1. Update yum


$ sudo yum update

2. Run the Docker installation script


$ curl -fsSL https://get.docker.com/ | sh

This script will add docker.repo and install Docker

3. Set the startup of Docker service


$ sudo systemctl enable docker.service

4. Start the Docker service


$ sudo yum update
0

5. Verify that Docker was installed successfully


$ sudo yum update
1

Related articles: