Docker(一) 安装
安装前置(Ubuntu 18.10)
- 替换源 https://www.bbsmax.com/A/obzbMrKBdE/
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
- 更新apt索引
sudo 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 -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
Docker软件安装
查看支持的docker版本
apt-cache madison docker-ce
安装docker
sudo apt-get install docker-ce -y
注: 可以指定版本安装docker: apt-get install docker-ce= -y
版本号如:5:19.03.63-0ubuntu-cosmic
网卡区别
安装前:只有ens33和lo网卡 安装后:docker启动后,
多出来了docker0网卡,网卡地址如:172.17.0.1
基本目录
docker基本目录简介
/etc/docker/ docker的认证目录
/var/lib/docker/ docker的应用目录
Docker服务相关命令
ubuntu安装完毕后,默认就开启服务了
dokcer服务命令格式
- systemctl start docker
- systemctl stop docker
- systemctl restart dockert
- systemctl status docker
- docker version
报错:System has not been booted with systemd as init system (PID 1). Can‘t operate
参考:https://blog.csdn.net/u012833399/article/details/128533933
例如:systemctl status docker => service docker status
删除docker命令:
yum remove docker-ce
rm -rf /var/lib/docker/
rm -rf /etc/docker
报错参考
下列软件包有未满足的依赖关系:
curl : 依赖: libcurl3 (= 7.35.0-1ubuntu2.5) 但是 7.47.0-1ubuntu2 正要被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
原因:libcurl3与系统原来的版本冲突
解决:直接卸载 sudo apt-get remove libcurl3
配置加速
-
修改daemon.json文件
在 /etc/docker/daemon.json 中写入如下内容(如果文件不存在请新建该文件)
(加速下载)https://blog.csdn.net/Funny_Ma/article/details/96478395
{"registry-mirrors":["https://hub-mirror.c.163.com"]}
-
重启服务
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
- 检查是否生效
在命令行执行 docker info,如果从结果中看到了如下内容,说明配置成功。
Registry Mirrors:
https://f3lu6ju1.mirror.aliyuncs.com