0%

docker install

参照官方https://docs.docker.com/install/linux/docker-ce/ubuntu/

ce是社区版

先切换ubuntu内镜像https://mirrors.ustc.edu.cn/repogen/

1、移除

1
$ sudo apt-get remove docker docker-engine docker.io

2、(可选)安装linux-image-extra-*包,以便docker使用aufs存储驱动

1
2
3
4
5
$ sudo apt-get update

$ sudo apt-get install \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual

3、支持https?

1
2
3
4
5
$ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common

4、add Docker的官方GPG key

1
2
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88

5、配置库

1
2
3
4
$ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

6、install

1
2
$ sudo apt-get update
$ sudo apt-get install docker-ce

7、test

1
$ sudo docker run hello-world

如果运行成功则网络无问题,若有,则需要配置docker代理,配置完重新运行“$ sudo docker run hello-world”进行验证

1
2
3
4
5
6
7
8
9
10
11
12
13
1.默认情况下这个配置文件夹并不存在,我们要创建它
$ mkdir -p /etc/systemd/system/docker.service.d
2.创建一个文件 /etc/systemd/system/docker.service.d/http-proxy.conf 文件内容如下:
[Service]
Environment="HTTP_PROXY=http://proxy_ip:proxy_port/"
Environment="HTTPS_PROXY=http://proxy_ip:proxy_port/"
Environment="NO_PROXY=localhost,127.0.0.1,localaddress,.localdomain.com"
3.刷新systemd配置:
$ sudo systemctl daemon-reload
4.用系统命令验证环境变量加上去没:
$ systemctl show --property=Environment docker
5.重启docker
$ sudo systemctl restart docker

8.安装docker-compose

1
$ sudo apt-get install docker-compose