docker部署安装

这一节,我们从软件源配置、基础软件安装、docker安装六个方面来学习

本教程的操作系统使用的是linux

软件源配置

官网参考:

https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#upgrade-docker-after-using-the-convenience-script

基础软件源

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

安装依赖软件

apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common -y

使用官方推荐源

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"

使用阿里云的源 推荐

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"

使用清华的源 推荐

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"

检查

apt-get update

docker软件安装

查看支持的docker版本

apt-cache madison docker-ce

安装docker

apt-get install docker-ce -y

注意:

可以指定版本安装docker:

apt-get install docker-ce=<VERSION> -y

启动docker

systemctl start docker
systemctl status docker

注意:
     ubuntu安装完毕后,默认就开启服务了

测试docker

docker version

网卡区别:

安装前:只有ens33和lo网卡

安装后:docker启动后,多出来了docker0网卡,网卡地址172.17.0.1

docker服务命令格式:

systemctl [参数] docker

参数详解:

start        开启服务

stop        关闭

restart    重启

status        状态

删除docker命令:

yum remove docker-ce
rm -rf /var/lib/docker/
rm -rf /etc/docker

基本目录

docker基本目录简介

/etc/docker/    docker的配置认证目录

/var/lib/docker/    docker的应用资源目录