发布日期:2019-12-30 14:39:00

参考文档https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-centos-7

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-centos-7

Step 1 — Installing Docker (使用Non-root user with sudo privileges.)

1.1 首先更新package数据库

sudo yum check-update

1.2 安装docker

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

# Executing docker install script, commit: f45d7c11389849ff46a6b4d94e0dd1ffebca32c1
+ sudo -E sh -c 'yum install -y -q yum-utils'
+ sudo -E sh -c 'yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'
Loaded plugins: fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sudo -E sh -c 'yum makecache'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                     | 3.6 kB     00:00     
docker-ce-stable                                         | 3.5 kB     00:00     
epel                                                     | 5.4 kB     00:00     
extras                                                   | 2.9 kB     00:00     
updates                                                  | 2.9 kB     00:00     
(1/14): base/7/x86_64/other_db                             | 2.6 MB   00:00     
(2/14): base/7/x86_64/filelists_db                         | 7.3 MB   00:00     
(3/14): docker-ce-stable/x86_64/updateinfo                 |   55 B   00:00     
(4/14): docker-ce-stable/x86_64/filelists_db               |  18 kB   00:00     
(5/14): epel/x86_64/prestodelta                            | 4.1 kB   00:00     
(6/14): epel/x86_64/filelists_db                           |  12 MB   00:00     
(7/14): epel/x86_64/updateinfo_zck                         | 1.5 MB   00:00     
(8/14): extras/7/x86_64/other_db                           | 100 kB   00:00     
(9/14): epel/x86_64/other_db                               | 3.3 MB   00:00     
(10/14): updates/7/x86_64/filelists_db                     | 3.3 MB   00:00     
(11/14): extras/7/x86_64/filelists_db                      | 207 kB   00:00     
(12/14): docker-ce-stable/x86_64/primary_db                |  37 kB   00:00     
(13/14): updates/7/x86_64/other_db                         | 368 kB   00:00     
(14/14): docker-ce-stable/x86_64/other_db                  | 111 kB   00:00     
Metadata Cache Created
+ '[' -n '' ']'
+ sudo -E sh -c 'yum install -y -q docker-ce'
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-19.03.5-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-19.03.5-3.el7.x86_64.rpm is not installed
Importing GPG key 0xH7621ssE9F315:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 06s0a 61dc5 1bs55 8as7f 74d2b 77aa cd52f eb6b 621e 9fs35
 From       : https://download.docker.com/linux/centos/gpg
setsebool:  SELinux is disabled.
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker xxx.xxx

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

1.2.1 默认运行docker需要root权限,如果不想sudo的话,可以将当前用户添加到docker group中

sudo usermod -aG docker xxx.xxx

1.3 启动docker

sudo systemctl start docker

1.4 查看docker状态

sudo systemctl status docker

docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2016-05-01 06:53:52 CDT; 1 weeks 3 days ago
     Docs: https://docs.docker.com
 Main PID: 749 (docker)

1.5 保证系统重庆后自动启动docker

sudo systemctl enable docker

发表评论