CentOS 7 install Docker CE

Translated from Get Docker CE for CentOS | Docker Docs, subject to Docker official documents
Click to view my [blog original] (https://abelsu7.top/2019/01/10/install-docker-ce-on-centos7/)

Preparation before installation##

System Requirements###

Uninstall the old version###

The package name of the old version of Docker in CentOS is docker or docker-engine. If you have installed an old version of Docker before, you need to uninstall the old version of Docker and related dependencies:

> sudo yum remove docker \
     docker-client \
     docker-client-latest \
     docker-common \
     docker-latest \
     docker-latest-logrotate \
     docker-logrotate \
     docker-selinux \
     docker-engine-selinux \
     docker-engine

If yum prompts Uninstall successful or No related package found, proceed to the next step.

Note: The contents of the /var/lib/docker/ directory, including images, containers, volume groups, networks and other files will be reserved. Docker CE's new package is named docker-ce.

Install Docker CE

There are three ways to install Docker CE, which can be selected according to actual needs:

  1. Establish Docker warehouse: The installation process and subsequent updates are convenient, Docker official recommendation.
  2. Download the RPM package and install manually: Manually manage updates. Suitable for offline environment.
  3. Automatic installation via installation script: Suitable for test and development environment.

Method 1: Establish a Docker warehouse

Before installing Docker CE for the first time, you need to create a Docker repository. After that, you can install and update Docker through the warehouse.

Build a warehouse

1.Install the required packages. yum-utils provides yum-config-manager tool, storage driver devicemapper depends on device-mapper-persistent-data and lvm2:

> sudo yum install -y yum-utils \
 device-mapper-persistent-data \
 lvm2
  1. Use the following command to create stable version of the repository:
> sudo yum-config-manager \
 - - add-repo \
 https://download.docker.com/linux/centos/docker-ce.repo

3.Optional: **Enable edge and testWarehouse. These repositories are included in the docker.repo file, but ** are disabled by default. They can be enabled together with the stable repository.

> sudo yum-config-manager --enable docker-ce-edge
> sudo yum-config-manager --enable docker-ce-test

Use the yum-config-manager command with the --disable parameter to disableedge** or test warehouse**, use the --enable parameter to Re-enable. For example, the following command will disable the edge repository:

> sudo yum-config-manager --disable docker-ce-edge

Starting from Docker17.06 version, releases of stable repository will also be pushed to edge and test repositories.
Click here to view **Docker official instructions on stable and edge.

Install Docker CE

  1. Use the following command install the latest version of Docker CE:
> sudo yum install docker-ce

If prompt whether to accept the GPG key, you need to verify whether the key fingerprint meets the following content, if it does, click accept to continue the installation:

060 A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35

If multiple Docker repositories are enabled and no version is specified in the yum install or yum update command, Docker with the latest version number in all repositories will be installed.

  1. To install the specified version of Docker CE, you need to list all available versions from the warehouse, and then choose to install as needed:
> yum list docker-ce --showduplicates | sort -r

docker-ce.x86_64            18.09.0.ce-1.el7.centos             docker-ce-stable

At this time, the format of the installation package name is docker-ce-<VERSION STRING> . For example, install Docker CE of version 18.03.0:

> sudo yum install docker-ce-18.03.0.ce

At this point Docker should have been installed, but it has not been started. New user groupdocker has also been created and is currently empty.

3.Start Docker:

> sudo systemctl start docker
  1. Run the hello-world image to verify that Docker is installed correctly:
> sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3. The Docker daemon created a newcontainerfrom that image which runs the
 executable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent it
 to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Upgrade Docker CE

If you need to upgrade Docker CE, you can choose to install the latest version of docker-ce according to the above installation tutorial to complete the upgrade.

Method 2: Download the RPM package and install manually

Install Docker CE

If you cannot use the Docker repository, you can download.rpminstallation package to manually install Docker CE.

  1. Go to https://download.docker.com/linux/centos/7/x86_64/stable/Packages/, download the RPM installation package of the corresponding version.

  2. Use the yum command to install the RPM package**:

> sudo yum install /path/to/package.rpm

3.Start Docker:

> sudo systemctl start docker
  1. Run the hello-world image to verify that Docker is installed correctly:
> sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3. The Docker daemon created a newcontainerfrom that image which runs the
 executable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent it
 to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Upgrade Docker CE

If you need to upgrade, you can download the new version of the RPM installation package and use the yum upgrade command to upgrade:

> sudo yum -y upgrade /path/to/package.rpm

Method 3: Install automatically through the installation script###

Through the one-click installation script provided by Docker, you can quickly install Docker CE in the development environment without interaction. get.docker.com and test.docker.com correspond to the edge and test versions respectively. Script source code is stored in docker-install repository .

Docker official It is not recommended to use the installation script in a production environment

The following example will use the script provided by get.docker.com Install the latest released version of Docker CE. If you want to install the latest test version, just replace the script with test.docker.com, and replace get with test in the following example command:

> curl -fsSL https://get.docker.com -o get-docker.sh
> sudo sh get-docker.sh

< output truncated>

If you need to allow nonroot** users to use Docker**, use the following command to **add the user to **dockeruser group:

> sudo usermod -aG docker your-user

Log out and log in again to take effect. After start Docker:

> sudo systemctl start docker

Run the hello-world image to verify that Docker is installed correctly:

> sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3. The Docker daemon created a newcontainerfrom that image which runs the
 executable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent it
 to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Uninstall Docker CE

1. Uninstall the Docker installation package###

> sudo yum remote docker-ce

2. Delete related files###

Mirrors, containers, volume groups and custom configuration files on the host need to be manually deleted:

> sudo rm -rf /var/lib/docker

Reference materials

Get Docker CE for CentOS | Docker Docs

Post-installation steps for Linux | Docker Docs

Docker Docs

Recommended Posts

CentOS 7 install Docker CE
CentOS 7 install Docker
CentOS7 install Docker
Centos7 install Docker
Centos7 install docker18
CentOS 6 install Docker
Centos8 install Docker
Install Docker on Centos7
CentOS 7 install Docker service
CentOS 8-dnf install docker
install Docker on centos6.5
Install Docker CE in yum under CentOS 7
Install docker transfer on Centos7
Install docker on Centos system
1.5 Install Centos7
How to install Docker CE on RHEL 8 / CentOS 8
Install MySql with Docker in CentOS7
Container study notes CentOS7 install Docker
Install and use docker under CentOS 6.8
Install Centos7 operating system in Docker
Centos6 install Python2.7.13
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
Centos7 install Python 3.6.
CentOS7 install MySQL
Centos7 install protobuf
CentOS7 install GlusterFS
ubuntu18.04 install docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Centos7 install Python2.7
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
Docker installation (CentOS7 installation)
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS7 install mysql
centOs install rabbitMQ
CentOS 7 install MySQL 5.6
docker install ubuntu
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos install Python3
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS7 docker installation
CentOS 7 install Java 1.8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab
Centos 7 install PostgreSQL
CentOS7 install MySQL8
CentOS 7 install Java 1.8