centOS7.0按照docker官网安装docker出现错误以及解决方法
centOS7.0按照docker官网安装docker出现错误以及解决方法测评环境:三丰免费云主机centos7 juicesshdocker官网安装的最新版的yum remove docker \docker-client \docker-client-latest \...
centOS7.0按照docker官网安装docker出现错误以及解决方法
测评环境:三丰免费云主机centos7 juicessh
docker官网安装的最新版的
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
运行 helloworld出现
Status: Downloaded newer image for hello-world:latest docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:293: copying bootstrap data to pipe caused \"write init-p: broken pipe\"": unknown.
后重装低版本的才成功!
yum erase docker-ce-cli-1:18.09.3-3.el7.x86_64
yum install -y docker-ce-18.03.1.ce
docker-ce-cli-1:18.09.3-3.el7.x86_64
file /usr/share/zsh/vendor-completions/_docker from install of docker-ce-18.03.1.ce-1.el7.centos.x86_64 conflicts with file from package docker-ce-cli-1:18.09.3-3.el7.x86_64
参考一下
https://www.jianshu.com/p/7d9ff93bc89e
CentOS 7 安装 Docker 和 Docker-Compose
Eniso
环境检查
进入 root
为了愉快,以下所有操作都是以 root 用户执行
sudo -i
查看 Linux 发行版本
[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
查看内核版本
Docker 要求 CentOS 系统的内核版本高于 3.10
[root@localhost /]# uname -r
3.10.0-123.el7.x86_64
结论
发行版本为 CentOS 7,满足 Docker 环境需求,接下来用 yum 安装 docker-ce。
注意:
3.10 版本的内核,可能无法正常运行 18.06.x 及以上版本的 docker(解决方法:升级内核或者降低 docker 版本),可能报下面的错误:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:293: copying bootstrap data to pipe caused "write init-p: broken pipe"": unknown.
安装 Docker
# 更新到最新 yum 包
yum update -y
# 卸载旧版本(如果安装过旧版本的话)
yum remove docker docker-common docker-selinux docker-engine docer-io
# 安装需要的软件包
# yum-util 提供 yum-config-manager 功能, 另外两个是 devicemapper 驱动依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
# 设置 yum 源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 查看所有仓库中所有 docker 版本,并选择特定版本安装
yum list docker-ce --showduplicates | sort -r
* updates: centos.ustc.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
* extras: centos.ustc.edu.cn
docker-ce.x86_64 3:18.09.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.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 17.12.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.09.1.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.06.2.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.0.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.03.2.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.0.ce-1.el7.centos docker-ce-stable
* base: centos.ustc.edu.cn
Available Packages
# 由于 repo 中默认只开启 stable 的仓库,故这里安装的是最新稳定版(18.09.2)
# 由于内核是 3.10 无法正常运行 18.06.x 及以上版本的 docker,所以不这么安装
# yum install -y docker-ce
# 经过测试发现,3.10 内核可以运行 18.03.1.ce
# yum install -y <FQPN>
yum install -y docker-ce-18.03.1.ce
# 启动并加入开机启动
systemctl start docker
systemctl enable docker
# 验证安装是否成功(有 client 和 service 两部分表示 docker 安装启动都成功了)
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
更改配置(如果有必要)
sudo vim /lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --graph=/home/docker/data
# 你可能会用到代理(如果原先没有Environment,可以添加)
Environment="HTTP_PROXY=http://0.0.0.0:8123" "HTTPS_PROXY=http://0.0.0.0:8123" "NO_PROXY=localhost,127.0.0.1,::1"
重启 docker 使配置生效
sudo systemctl daemon-reload
sudo systemctl restart docker
安装 Docker-Compose
通过访问 https://github.com/docker/compose/releases/latest 得到最新的 docker-compose 版本(例如:1.23.2),然后执行一下命令安装 docker-compose
# 下载最新版本的 docker-compose 到 /usr/bin 目录下
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose
# 给 docker-compose 授权
chmod +x /usr/bin/docker-compose
FAQ
1、yum update -y 失败
[root@localhost ~]# yum update -y
Loaded plugins: fastestmirror, langpacks
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Disable the repository, so yum won't use it by default. Yum will then
just ignore the repository until you permanently enable it again or use
--enablerepo for temporary usage:
yum-config-manager --disable <repoid>
4. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
如果遇到上面的错误,通过修改 /etc/resolv.conf,添加如下内容,再次执行 yum update -y
nameserver 8.8.8.8
search localdomain
2、yum install -y docker-ce-18.03.1.ce失败
Transaction check error:
file /usr/bin/docker from install of docker-ce-18.03.1.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/docker-containerd from install of docker-ce-18.03.1.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/docker-containerd-shim from install of docker-ce-18.03.1.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
file /usr/bin/dockerd from install of docker-ce-18.03.1.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
卸载旧版本的包
yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
再次安装 docker
yum install -y docker-ce-18.03.1.ce
自己的实践
[root@localhost ~]# docker version
Client:
Version: 18.09.3
API version: 1.39
Go version: go1.10.8
Git commit: 774a1f4
Built: Thu Feb 28 06:33:21 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.3
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 774a1f4
Built: Thu Feb 28 06:02:24 2019
OS/Arch: linux/amd64
Experimental: false
[root@localhost ~]# docker container run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535 Status: Downloaded newer image for hello-world:latest docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:293: copying bootstrap data to pipe caused \"write init-p: broken pipe\"": unknown.
[root@localhost ~]# docker container run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
6cf436f81810: Pull complete
987088a85b96: Pull complete
b4624b3efe06: Pull complete
d42beb8ded59: Pull complete
Digest: sha256:7a47ccc3bbe8a451b500d2b53104868b46d60ee8f5b35a24b41a86077c650210
Status: Downloaded newer image for ubuntu:latest
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:293: copying bootstrap data to pipe caused \"write init-p: broken pipe\"": unknown.
[root@localhost ~]# docker container run -it ubuntu sh
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:293: copying bootstrap data to pipe caused \"write init-p: broken pipe\"": unknown.
[root@localhost ~]# uname -r
3.10.0-123.el7.x86_64
[root@localhost ~]# docker version
Client:
Version: 18.09.3
API version: 1.39
Go version: go1.10.8
Git commit: 774a1f4
Built: Thu Feb 28 06:33:21 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.3
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 774a1f4
Built: Thu Feb 28 06:02:24 2019
OS/Arch: linux/amd64
Experimental: false
[root@localhost ~]# yum remove docker docker-common docker-selinux docker-engine docer-io
已加载插件:fastestmirror
参数 docker 没有匹配
参数 docker-common 没有匹配
参数 docker-engine 没有匹配
参数 docer-io 没有匹配
正在解决依赖关系
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.74-1.el7 将被 删除
--> 正在处理依赖关系 container-selinux >= 2.9,它被软件包 3:docker-ce-18.09.3-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.18.09.3-3.el7 将被 删除
--> 解决依赖关系完成
依赖关系解决
======================================================================== Package 架构 版本 源 大小
========================================================================正在删除:
container-selinux noarch 2:2.74-1.el7 @extras 37 k
为依&ker-ce x86_64 3:18.09.3-3.el7 @docker-ce-stable 81 M
事务概要
========================================================================移除 1 软件包 (+1 依赖软件包)
正在删除 : 3:docker-ce-18.09.3-3.el7.x86_64 1/2 正在删除 : 2:container-selinux-2.74-1.el7.noarch 2/2 验证中 : 2:container-selinux-2.74-1.el7.noarch 1/2 验证中 : 3:docker-ce-18.09.3-3.el7.x86_64 2/2
删除:
container-selinux.noarch 2:2.74-1.el7
作为依赖被删除:
docker-ce.x86_64 3:18.09.3-3.el7
完毕!
[root@localhost ~]# yum update
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.neusoft.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 ModemManager-glib.x86_64.0.1.1.0-6.git20130913.el7 将被 升级
---> 软件包 ModemManager-glib.x86_64.0.1.6.10-1.el7 将被 更新
---> 软件包 NetworkManager.x86_64.1.0.9.9.1-13.git20140326.4dba720.el7 将被 取代
---> 软件包 NetworkManager.x86_64.1.1.12.0-8.el7_6 将被 舍弃
--> 正在处理依赖关系 NetworkManager-libnm(x86-64) = 1:1.12.0-8.el7_6,它被软件包 1:NetworkManager-1.12.0-8.el7_6.x86_64 需要
--> 正在处理依赖关系 libnm.so.0(libnm_1_8_0)(64bit),它被软件包 1:NetworkManager-1.12.0-8.el7_6.x86_64 需要
--> 正在处理依赖关系 libnm.so.0(libnm_1_6_0)(64bit),它被软件包 1:NetworkManager
l7 base 289 k
事务概要
========================================================================安装 14 软件包 (+21 依赖软件包)
升级 198 软件包
总下载量:247 M
Is this ok [y/d/N]: y
gobject3-base.x86_64 0:3.8.2-4.el7
完毕!
[root@localhost ~]# uname -r
3.10.0-123.el7.x86_64
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.neusoft.edu.cn
软件包 yum-utils-1.1.31-50.el7.noarch 已安装并且是最新版本
软件包 device-mapper-persistent-data-0.7.3-3.el7.x86_64 已安装并且是最新版本
软件包 7:lvm2-2.02.180-10.el7_6.3.x86_64 已安装并且是最新版本
无须任何处理
[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
已加载插件: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
[root@localhost ~]# yum install -y docker-ce-18.03.1.ce
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.neusoft.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.0.18.03.1.ce-1.el7.centos 将被 安装
--> 正在处理依赖关系 container-selinux >= 2.9,它被软件包
务概要
========================================================================安装 1 软件包 (+3 依赖软件包)
总下载量:35 M
安装大小:35 M
Downloading packages:
(1/4): container-selinux-2.74-1.el7.noarch.rpm | 38 kB 00:00 (2/4): pigz-2.3.3-1.el7.centos.x86_64.rpm | 68 kB 00:00 (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.r 13% [===== (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.r 13% [===== (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.r 14% [===== (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.r 14% [=====- (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.r 14% [=====- (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.r 14% [=====- (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.r 14% [=====- (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.r 14% [=====- (4/4): docker-ce-18.03.1.ce-1.el7.centos.x86_64.rp | 35 MB 02:50 ------------------------------------------------------------------------总计 208 kB/s | 35 MB 02:50 Running transaction check
Running transaction test
Transaction check error:
file /usr/bin/docker from install of docker-ce-18.03.1.ce-1.el7.centos.x86_64 conflicts with file from package docker-ce-cli-1:18.09.3-3.el7.x86_64
file /usr/share/bash-completion/completions/docker from install of docker-ce-18.03.1.ce-1.el7.centos.x86_64 conflicts with file from package docker-ce-cli-1:18.09.3-3.el7.x86_64
file /usr/share/fish/vendor_completions.d/docker.fish from install of docker-ce-18.03.1.ce-1.el7.centos.x86_64 conflicts with file from package docker-ce-cli-1:18.09.3-3.el7.x86_64
file /usr/share/man/man1/docker-attach.1.gz from install of
错误概要
-------------
[root@localhost man1]# yum erase docker-ce-cli-1:18.09.3-3.el7.x86_64
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce-cli.x86_64.1.18.09.3-3.el7 将被 删除
--> 解决依赖关系完成
依赖关系解决
======================================================================== Package 架构 版本 源 大小
========================================================================正在删除:
docker-ce-cli x86_64 1:18.09.3-3.el7 @docker-ce-stable 66 M
事务概要
========================================================================移除 1 软件包
安装大小:66 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : 1:docker-ce-cli-18.09.3-3.el7.x86_64 1/1 验证中 : 1:docker-ce-cli-18.09.3-3.el7.x86_64 1/1
删除:
docker-ce-cli.x86_64 1:18.09.3-3.el7
完毕!
[root@localhost man1]# yum install -y docker-ce-18.03.1.ce
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.neusoft.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 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 需要
--> 正在处理依赖关系 libltdl.so.7()(64bit),它被软件包 docker-ce-18.03.1.ce-1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.74-1.el7 将被 安装
---> 软件包 libtool-ltdl.x86_64.0.2.4.2-22.el7_3 将被 安装
---> 软件包 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.74-1.el7 extras 38 k
libtool-ltdl x86_64 2.4.2-22.el7_3 base 49 k
pigz x86_64 2.3.3-1.el7.centos extras 68 k
事务概要
========================================================================安装 1 软件包 (+3 依赖软件包)
总计:35 M
安装大小:35 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : pigz-2.3.3-1.el7.centos.x86_64 1/4 正在安装 : libtool-ltdl-2.4.2-22.el7_3.x86_64 2/4 正在安装 : 2:container-selinux-2.74-1.el7.noarch 3/4 正在安装 : docker-ce-18.03.1.ce-1.el7.centos.x86_64 4/4 验证中 : 2:container-selinux-2.74-1.el7.noarch 1/4 验证中 : libtool-ltdl-2.4.2-22.el7_3.x86_64 2/4 验证中 : docker-ce-18.03.1.ce-1.el7.centos.x86_64 3/4 验证中 : pigz-2.3.3-1.el7.centos.x86_64 4/4
已安装:
docker-ce.x86_64 0:18.03.1.ce-1.el7.centos
作为依赖被安装:
container-selinux.noarch 2:2.74-1.el7 libtool-ltdl.x86_64 0:2.4.2-22.el7_3 pigz.x86_64 0:2.3.3-1.el7.centos
完毕!
[root@localhost man1]# systemctl start docker
[root@localhost man1]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost man1]# 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
[root@localhost man1]# docker container 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:
更多推荐
所有评论(0)