Centos安装docker#避免很多坑

Posted mumengyun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos安装docker#避免很多坑相关的知识,希望对你有一定的参考价值。

采用yum方式安装

安装:

step 1: 安装必要的一些系统工具

yum install -y yum-utils device-mapper-persistent-data lvm2

Step 2: 添加软件源信息

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Step 3: 更新并安装 Docker-CE

yum makecache fast
yum -y install docker-ce

Step 4: 开启Docker服务

service docker start
安装指定版本的Docker-CE:

Step 1: 查找Docker-CE的版本:

yum list docker-ce.x86_64 --showduplicates | sort -r
Loading mirror speeds from cached hostfile
Loaded plugins: branch, fastestmirror, langpacks
docker-ce.x86_64 17.03.1.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
Available Packages

Step2 : 安装指定版本的Docker-CE: (VERSION 例如上面的17.03.0.ce.1-1.el7.centos)

yum -y install docker-ce-[VERSION]
安装校验:
docker version
配置加速器:(适用于此版本)
systemctl enable docker(产生下面的文件)

vim /etc/systemd/system/multi-user.target.wants/docker.service
将ExecStart=/usr/bin/dockerd
修改为
ExecStart=/usr/bin/dockerd --registry-mirror=https://registry.docker-cn.com
此为阿里云加速器,执行 ps -ef | grep docker 或者docker info 也可以看见加速ok
systemctl daemon-reload
systemctl start docker

安装docker-compose

需要先安装企业版linux附加包(epel)
$ yum -y install epel-release
安装pip
$ yum -y install python-pip
更新pip
$ pip install --upgrade pip
//国内原加速
$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
安装docker-compose
$ pip install docker-compose
//国内原加速
$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose
查看docker-compose版本信息
$ docker-compose --version














以上是关于Centos安装docker#避免很多坑的主要内容,如果未能解决你的问题,请参考以下文章

使用docker安装Jenkins

linux centos7安装tomcat7以及遇到坑的解决办法

linux centos7安装tomcat7以及遇到坑的解决办法

基于Docker搭建MySQL主从复制

基于 Docker 搭建 MySQL 主从复制

docker+nginx 踩坑之路