centos7安装docker

 

vi  /etc/yum.repos.d/docker.repo

[dockerrepo]

name=Docker Repository

baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/

enabled=1

gpgcheck=1

gpgkey=https://yum.dockerproject.org/gpg

yum install docker-engine

启动失败

[root@yanzh opt]# service docker start
Redirecting to /bin/systemctl start docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@yanzh opt]# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: start-limit) since Sun 2019-02-24 14:29:56 PST; 23s ago
     Docs: https://docs.docker.com
  Process: 8401 ExecStart=/usr/bin/dockerd (code=exited, status=1/FAILURE)
 Main PID: 8401 (code=exited, status=1/FAILURE)

Feb 24 14:29:56 yanzh systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Feb 24 14:29:56 yanzh systemd[1]: Failed to start Docker Application Container Engine.
Feb 24 14:29:56 yanzh systemd[1]: Unit docker.service entered failed state.
Feb 24 14:29:56 yanzh systemd[1]: docker.service failed.
Feb 24 14:29:56 yanzh systemd[1]: docker.service holdoff time over, scheduling restart.
Feb 24 14:29:56 yanzh systemd[1]: Stopped Docker Application Container Engine.
Feb 24 14:29:56 yanzh systemd[1]: start request repeated too quickly for docker.service
Feb 24 14:29:56 yanzh systemd[1]: Failed to start Docker Application Container Engine.
Feb 24 14:29:56 yanzh systemd[1]: Unit docker.service entered failed state.
Feb 24 14:29:56 yanzh systemd[1]: docker.service failed.
 

清理

[root@yanzh opt]# yum remove docker
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker
No Packages marked for removal
[root@yanzh opt]# docker -v
Docker version 17.05.0-ce, build 89658be
[root@yanzh opt]# yum remove docker-selinux
Loaded plugins: fastestmirror, langpacks
No Match for argument: docker-selinux
No Packages marked for removal
[root@yanzh opt]# docker -v
Docker version 17.05.0-ce, build 89658be
[root@yanzh opt]# 
[root@yanzh opt]# 
[root@yanzh opt]# 
[root@yanzh opt]# 
[root@yanzh opt]# 
[root@yanzh opt]# 
[root@yanzh opt]# vi  /etc/yum.repos.d/docker.repo
[root@yanzh opt]# docker version
Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:06:25 2017
 OS/Arch:      linux/amd64
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@yanzh opt]# 
 

重新安装curl -fsSL https://get.docker.com/ | sh

[root@yanzh opt]# curl -fsSL https://get.docker.com/ | sh
# Executing docker install script, commit: 40b1b76
Warning: the "docker" command appears to already exist on this system.

If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.

If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.

You may press Ctrl+C now to abort this script.
+ sleep 20
+ sh -c 'yum install -y -q yum-utils'
Package yum-utils-1.1.31-50.el7.noarch already installed and latest version
+ sh -c 'yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'
Loaded plugins: fastestmirror, langpacks
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
+ '[' edge '!=' stable ']'
+ sh -c 'yum-config-manager --disable docker-ce-*'
Loaded plugins: fastestmirror, langpacks
==================================================================================== repo: docker-ce-edge =====================================================================================
[docker-ce-edge]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = https://download.docker.com/linux/centos/7/x86_64/edge
cache = 0
cachedir = /var/cache/yum/x86_64/7/docker-ce-edge
check_config_file_age =

.

.

.

updates                                                                                                                                                                 | 3.4 kB  00:00:00     
(1/13): base/7/x86_64/other_db                                                                                                                                          | 2.6 MB  00:00:01     
(2/13): docker-ce-edge/x86_64/updateinfo                                                                                                                                |   55 B  00:00:01     
(3/13): docker-ce-edge/x86_64/filelists_db                                                                                                                              |  14 kB  00:00:01     
(4/13): extras/7/x86_64/filelists_db                                                                                                                                    | 231 kB  00:00:00     
(5/13): extras/7/x86_64/prestodelta                                                                                                                                     |  47 kB  00:00:00     
(6/13): extras/7/x86_64/other_db                                                                                                                                        | 118 kB  00:00:00     
(7/13): docker-ce-edge/x86_64/primary_db                                                                                                                                |  27 kB  00:00:00     
(8/13): docker-ce-edge/x86_64/other_db                                                                                                                                  |  78 kB  00:00:01     
(9/13): updates/7/x86_64/prestodelta                                                                                                                                    | 341 kB  00:00:00     
(10/13): updates/7/x86_64/filelists_db                                                                                                                                  | 1.9 MB  00:00:01     
(11/13): updates/7/x86_64/other_db                                                                                                                                      | 340 kB  00:00:01     
(12/13): dockerrepo/7/filelists_db                                                                                                                                      |  40 kB  00:00:04     
(13/13): dockerrepo/7/other_db                                                                                                                                          | 652 kB  00:00:18     
Metadata Cache Created
+ sh -c 'yum install -y -q docker-ce'

warning: /var/cache/yum/x86_64/7/docker-ce-edge/packages/docker-ce-18.09.2-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-18.09.2-3.el7.x86_64.rpm is not installed
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://download.docker.com/linux/centos/gpg
+ sh -c 'docker version'
Client:
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        6247962
 Built:             Sun Feb 10 04:13:27 2019
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
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 your-user

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.

** DOCKER ENGINE - ENTERPRISE **

If you’re ready for production workloads, Docker Engine - Enterprise also includes:

  * SLA-backed technical support
  * Extended lifecycle maintenance policy for patches and hotfixes
  * Access to certified ecosystem content

** Learn more at https://dockr.ly/engine2 **

ACTIVATE your own engine to Docker Engine - Enterprise using:

  sudo docker engine activate

上述过程得一会儿时间

安装成功,启动

[root@yanzh ~]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@yanzh ~]# docker version
Client:
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        6247962
 Built:             Sun Feb 10 04:13:27 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 03:47:25 2019
  OS/Arch:          linux/amd64
  Experimental:     false
[root@yanzh ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
 

docker 卸载指令

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

rm -rf /etc/systemd/system/docker.service.d

rm -rf /var/lib/docker

rm -rf /var/run/docker

 

docker配置国内仓库地址方法

在这个文件/etc/docker/daemon.json(如果没有自己新建)

加 {
  "registry-mirrors": ["http://hub-mirror.c.163.com"]
}

安装指定版本docker

https://www.cnblogs.com/harlanzhang/p/9965534.html

启动指令

systemctl start docker
systemctl enable docker
systemctl status docker
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值