Docker [Docker 学习笔记] 通过 Centos7 安装 Docker 18.03.1-ce

大海 · 2018年09月23日 · 1680 次阅读
[sks@bogon ~]$ uname -r
3.10.0-862.el7.x86_64
[sks@bogon ~]$ sudo yum update
[sks@bogon ~]$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
[sudo] sks 的密码:
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
软件包 yum-utils-1.1.31-46.el7_5.noarch 已安装并且是最新版本
软件包 device-mapper-persistent-data-0.7.3-3.el7.x86_64 已安装并且是最新版本
软件包 7:lvm2-2.02.177-4.el7.x86_64 已安装并且是最新版本
无须任何处理
[sks@bogon ~]$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[sks@bogon ~]$ 
[sks@bogon ~]$ ---------------------
bash: ---------------------: 未找到命令...
[sks@bogon ~]$ 
[sks@bogon ~]$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[sks@bogon ~]$ 
[sks@bogon ~]$ ---------------------
bash: ---------------------: 未找到命令...
[sks@bogon ~]$ 
[sks@bogon ~]$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[sks@bogon ~]$ yum list docker-ce --showduplicates
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
 * base: mirrors.huaweicloud.com
 * extras: mirrors.cn99.com
 * updates: centos.ustc.edu.cn
docker-ce-stable                                                | 2.9 kB  00:00:00     
docker-ce-stable/x86_64/primary_db                              |  16 kB  00:00:00     
可安装的软件包
docker-ce.x86_64                17.03.0.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.03.1.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.03.2.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.03.3.ce-1.el7                       docker-ce-stable
docker-ce.x86_64                17.06.0.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.06.1.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.06.2.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.09.0.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.09.1.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.12.0.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                17.12.1.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                18.03.0.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                18.03.1.ce-1.el7.centos                docker-ce-stable
docker-ce.x86_64                18.06.0.ce-3.el7                       docker-ce-stable
docker-ce.x86_64                18.06.1.ce-3.el7                       docker-ce-stable
[sks@bogon ~]$ sudo yum install docker-ce-18.03.1.ce
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
docker-ce-stable                                                | 2.9 kB  00:00:00     
docker-ce-stable/x86_64/primary_db                              |  16 kB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.0.18.03.1.ce-1.el7.centos 将被 安装
--> 正在处理依赖关系 container-selinux >= 2.9,它被软件包 docker-ce-18.03.1.ce-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 pigz,它被软件包 docker-ce-18.03.1.ce-1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.68-1.el7 将被 安装
---> 软件包 pigz.x86_64.0.2.3.3-1.el7.centos 将被 安装
--> 解决依赖关系完成

依赖关系解决

=======================================================================================
 Package              架构      版本                         源                   大小
=======================================================================================
正在安装:
 docker-ce            x86_64    18.03.1.ce-1.el7.centos      docker-ce-stable     35 M
为依赖而安装:
 container-selinux    noarch    2:2.68-1.el7                 extras               36 k
 pigz                 x86_64    2.3.3-1.el7.centos           extras               68 k

事务概要
=======================================================================================
安装  1 软件包 (+2 依赖软件包)

总下载量:35 M
安装大小:35 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): container-selinux-2.68-1.el7.noarch.rpm                  |  36 kB  00:00:00     
(2/3): pigz-2.3.3-1.el7.centos.x86_64.rpm                       |  68 kB  00:00:01     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm 的公钥尚未安装
(3/3): docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm             |  35 MB  00:00:05     
---------------------------------------------------------------------------------------
总计                                                      6.8 MB/s |  35 MB  00:05     
从 https://mirrors.aliyun.com/docker-ce/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
 用户ID     : "Docker Release (CE rpm) <docker@docker.com>"
 指纹       : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 来自       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : pigz-2.3.3-1.el7.centos.x86_64                                     1/3 
  正在安装    : 2:container-selinux-2.68-1.el7.noarch                              2/3 
  正在安装    : docker-ce-18.03.1.ce-1.el7.centos.x86_64                           3/3 
  验证中      : docker-ce-18.03.1.ce-1.el7.centos.x86_64                           1/3 
  验证中      : 2:container-selinux-2.68-1.el7.noarch                              2/3 
  验证中      : pigz-2.3.3-1.el7.centos.x86_64                                     3/3 

已安装:
  docker-ce.x86_64 0:18.03.1.ce-1.el7.centos                                           

作为依赖被安装:
  container-selinux.noarch 2:2.68-1.el7        pigz.x86_64 0:2.3.3-1.el7.centos       

完毕!
[sks@bogon ~]$ systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[sks@bogon ~]$ systemctl start docker
[sks@bogon ~]$ sudo mkdir -p /etc/docker
[sks@bogon ~]$ sudo tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://****.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://****.mirror.aliyuncs.com"]
}
[sks@bogon ~]$ sudo systemctl daemon-reload
[sks@bogon ~]$ sudo systemctl restart docker
[sks@bogon ~]$ docker run hello-world
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.37/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
[sks@bogon ~]$ sudo gpasswd -a ${USER} docker
正在将用户“sks”加入到“docker”组中
[sks@bogon ~]$ sudo su
[root@bogon sks]# su sks
[sks@bogon ~]$ sudo yum install docker-compose
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.cn99.com
没有可用软件包 docker-compose。
错误:无须任何处理
[sks@bogon ~]$ docker version
Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:20:16 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:23:58 2018
  OS/Arch:      linux/amd64
  Experimental: false
[sks@bogon ~]$ 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 new container from 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/
[sks@bogon ~]$ 
[sks@bogon ~]$ 
[sks@bogon ~]$ 
[sks@bogon ~]$  docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx-file          v1                  b8941d2edfa5        14 seconds ago      418MB
<none>              <none>              4b11889cf672        12 minutes ago      200MB
<none>              <none>              6a8accb69024        18 minutes ago      200MB
centos              latest              75835a67d134        2 weeks ago         200MB
test/ubuntu         v1.0                2c47cf17950f        4 weeks ago         69.8MB
hello-world         latest              4ab4c602aa5e        6 weeks ago         1.84kB
ubuntu              18.04               cd6d8154f1e1        7 weeks ago         84.1MB
ubuntu              latest              cd6d8154f1e1        7 weeks ago         84.1MB
centos              7                   5182e96772bf        2 months ago        200MB
[sks@bogon ~]$  docker rmi 4b11889cf672
Deleted: sha256:4b11889cf672b579f11c568fd6b6f102f2a20f65ea07f9e58134129c58c6faf6
[sks@bogon ~]$  docker rmi 6a8accb69024
Deleted: sha256:6a8accb69024e856a6f6b60cee767bf744aeebfefbc3bf760459a7ac1727b0b0
[sks@bogon ~]$  docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx-file          v1                  b8941d2edfa5        3 minutes ago       418MB
centos              latest              75835a67d134        2 weeks ago         200MB
test/ubuntu         v1.0                2c47cf17950f        4 weeks ago         69.8MB
hello-world         latest              4ab4c602aa5e        6 weeks ago         1.84kB
ubuntu              18.04               cd6d8154f1e1        7 weeks ago         84.1MB
ubuntu              latest              cd6d8154f1e1        7 weeks ago         84.1MB
centos              7                   5182e96772bf        2 months ago        200MB
[sks@bogon ~]$ 

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册