Docker安装
1)基础软件源
cd /etc/apt/
mv sources.list sources.list.bak
vim sources.list
# sohu shangdong
deb http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse
# 163 guangdong
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
# tsinghua.edu
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# aliyun
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
# neu.edu
deb http://mirror.neu.edu.cn/ubuntu/ xenial main restricted universe multiverse partner
deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
2)安装依赖软件
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common -y
3)使用官方推荐源
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
使用阿里云的源{推荐1}
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
使用清华的源{推荐2}
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
4)检查
apt-get update
5)docker软件安装
# 查看支持的docker版本
apt-cache madison docker-ce
# 安装docker
apt-get install docker-ce -y
# 注:可以指定版本安装docker
apt-get install docker-ce=<VERSION> -y
6)启动docker
systemctl start docker
systemctl status docker
7)测试docker
docker version
8)网卡区别:
安装前:只有ens33和lo网卡 安装后:docker启动后,多出来了docker0网卡,网卡地址172.17.0.1
9)docker服务命令格式
systemctl [参数] docker
参数详解:
start 开启服务
stop 关闭
restart 重启
status 状态
删除docker命令:
yum remove docker-ce
rm -rf /var/lib/docker/
rm -rf /etc/docker
基本目录:
/etc/docker/ docker的认证目录
/var/lib/docker/ docker的应用目录
docker加速器
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://74f21445.m.daocloud.io
加速器配置
1)修改daemon.json文件,增加绿色背景字体内容
# cat /etc/docker/daemon.json
{"registry-mirrors": ["http://74f21445.m.daocloud.io"], "insecure-registries": []}
注意:docker cloud加速器的默认内容是少了一条配置,所以我们要编辑文件在后面加上绿色背景的内容,然后再重启docker
2)重启docker
systemctl restart docker