Centos环境docker的正确安装及疑难杂症
根据官方文档:https://docs.docker.com/install/linux/docker-ce/centos/搭建docker
1.卸载docker旧版本:
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\
2.安装相关工具类:
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
3.配置docker仓库:
sudo 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
Could not fetch/save url https://download.docker.com/linux/centos/docker-ce.repo to file /etc/yum.repos.d/docker-ce.repo
: [Errno ] curl# - "TCP connection reset by peer
这是由于国内访问不到docker官方镜像的缘故
可以通过aliyun的源来完成:
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
出现以下内容则表示docker仓库配置成功:
Loaded plugins: fastestmirror
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
4.安装docker
sudo yum install docker-ce
出现以下异常:
Loaded plugins: fastestmirror
base
https://download-stage.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer"
Trying other mirror.
One of the configured repositories failed (Docker CE Stable - x86_64),
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: . Contact the upstream for the repository and get them to fix the problem. . 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). . Run the command with the repository temporarily disabled
yum --disablerepo=docker-ce-stable ... . Disable the repository permanently, 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 docker-ce-stable
or
subscription-manager repos --disable=docker-ce-stable . 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=docker-ce-stable.skip_if_unavailable=true failure: repodata/repomd.xml from docker-ce-stable: [Errno ] No more mirrors to try.
https://download-stage.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml: [Errno 14] curl#35 - "TCP connection reset by peer"
分析原因为:阿里的镜像库文件也指向docker官方库,所以需要修改库文件
sudo vim /etc/yum.repos.d/docker-ce.repo
通过命令把https://download-stage.docker.com替换为http://mirrors.aliyun.com/docker-ce
命令如下:
:%s#https://download-stage.docker.com#http://mirrors.aliyun.com/docker-ce#g
再执行docker的安装命令即可安装成功。
sudo yum install docker-ce
内容如下:
Installed:
docker-ce.x86_64 :18.03..ce-.el7.centos Dependency Installed:
audit-libs-python.x86_64 :2.7.-.el7 checkpolicy.x86_64 :2.5-.el7 container-selinux.noarch :2.42-.gitad8f0f7.el7 libcgroup.x86_64
libtool-ltdl.x86_64 :2.4.-.el7_3 pigz.x86_64 :2.3.-.el7.centos policycoreutils-python.x86_64 :2.5-17.1.el7 python-IPy.noarch Complete!
5.验证docker安装成功:
启动docker:
sudo systemctl start docker
验证docker:
sudo docker run hello-world
则会出现以下异常:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pulling fs layer
docker: error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/e3/e38bc07ac18e
See 'docker run --help'.
此错误也是网络问题:出现这个问题原因为国内网络问题,无法连接到 docker hub。
配置阿里云的docker镜像库:在阿里云开通容器镜像服务拿到加速地址在执行以下命令:
也可以:
好在国内已经有 daocloud,docker指定该源即可。
vi /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target [Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd --registry-mirror=http://f2d6cb40.m.daocloud.io
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd and above support this version.
#TasksMax=infinity
TimeoutStartSec=
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=
StartLimitInterval=60s [Install]
WantedBy=multi-user.target
重启docker服务:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
再次验证docker:
sudo docker run hello-world
出现一下内容表示验证成功:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
Status: Downloaded newer image for hello-world:latest Hello from Docker!
This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps:
. The Docker client contacted the Docker daemon.
. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
. 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/engine/userguide/
Centos环境docker的正确安装及疑难杂症的更多相关文章
- CentOS环境Docker安装教程(官方推荐的docker三种方式安装)
CentOS环境Docker安装教程(官方推荐的docker三种方式安装) 一.使用yum方式安装 1.安装依赖包 $ sudo yum install -y yum-utils device-map ...
- centos环境 使用kubeadm快速安装k8s集群v1.16.2
全程使用root用户运行,宿主机需要连接外网 浏览一下官方kubeadm[有些镜像用不了] https://kubernetes.io/docs/setup/production-environmen ...
- vagrant + virtualbox安装centos环境+docker安装
1. 下载vagrant 并安装,安装完成后,输入vagrant回车查看是否安装成功 2. 下载virtualbox.box并安装,安装完成后. 3. 创建虚拟机文件夹,例如.F:/vmimg/fir ...
- MPSOC之3——centos环境配置及petalinux安装及使用
ubuntu虽然能正常安装,但是build时会出现闪退情况,闪退后一切归零,没啥错误提示,改用centos来安装petalinux. 0.环境 vmware pro 14,centos 7.3 pet ...
- centos install docker setup centos7 安装docker
centos7 安装docker 1: 安装必要的一些系统工具sudo yum install -y yum-utils device-mapper-persistent-data lvm2 2: 添 ...
- CentOS环境下通过YUM安装软件,搭建lnmp环境
安装nginx.php-fpm和mysql. yum install nginx yum install php-fpm yum install mysql CentOS下LNMP环境配置 1. 配置 ...
- centos环境下使用CPAN安装perl模块
首先安装CPAN yum install perl-CPAN 进入cpan环境 perl -MCPAN -e shell 安装模块(以Tk为例) cpan>install Tk 退出 cpan& ...
- 全网最详细的大数据集群环境下如何正确安装并配置多个不同版本的Cloudera Hue(图文详解)
不多说,直接上干货! 为什么要写这么一篇博文呢? 是因为啊,对于Hue不同版本之间,其实,差异还是相对来说有点大的,具体,大家在使用的时候亲身体会就知道了,比如一些提示和界面. 全网最详细的大数据集群 ...
- 自动化测试平台环境docker部署
参考资料:testin云测 https://www.testin.cn接口自动化测试平台:http://120.79.232.23星云测试 http://www.threadingtest.com腾讯 ...
随机推荐
- JDBC详解2
day18总结 今日思维导图: 今日内容 事务 连接池 ThreadLocal BaseServlet自定义Servlet父类(只要求会用,不要求会写) DBUtils à commons-dbuti ...
- 北京君正集成电路的Newton平台--穿戴式
版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/hellomxj1/article/details/25324125 Newton1开发平台 • 很适合 ...
- Adam 算法
简介 Adam 是一种可以替代传统随机梯度下降(SGD)过程的一阶优化算法,它能基于训练数据迭代地更新神经网络权重.Adam 最开始是由 OpenAI 的 Diederik Kingma 和多伦多大学 ...
- C# 汉字编码GB2312转换
功能界面 源码: using System; using System.Collections.Generic; using System.ComponentModel; using System.D ...
- sql把字符数组转换成表
需求:把字符串1,2,3变成表里的行数据 方法:用自定义函数实现 /* 获取字符串数组的 Table */ from sysobjects where id = object_id('Get_StrA ...
- 【leetcode刷题笔记】Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in ...
- Apache 的 httpd.conf 注释
ServerRoot “/usr/local“ ServerRoot用于指定守护进程httpd的运行目录,httpd在启动之后将自动将进程的当前目录改变为这个目录,因此如果设置文件中指定的文件或目录是 ...
- 剑指offer——翻转单词顺序VS左旋转字符串
字符串的交换等,注意判断字符串的是否为NULL,以及判断边界等. #include <iostream> #include <string> using namespace s ...
- 操作系统原理2——OS结构
操作系统原理2——OS结构 计算机系统是由硬件系统和软件系统两部分组成, 操作系统是软件系统的一个组成部分,它是直接在硬件系统的基础上工作的,所以在研究操作系统之前,先必须对计算机系统的结构有一个 ...
- 吴恩达机器学习笔记(四) —— BP神经网络
主要内容: 一.模型简介 二.一些变量所代表的含义 三.代价函数 四.Forward Propagation 五.Back Propagation 六.算法流程 待解决问题: 视频中通过指出:当特征变 ...