系統(tǒng) ubuntu 16.04
1,添加docker源
在 /etc/apt/source.list 最后加入:
deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
2恋腕,sudo apt update
3肮疗,sudo apt install docker-ce
4趟紊,添加docker國(guó)內(nèi)加速器
? ? 可以用阿里云或者dao的往衷,都需要注冊(cè)骑篙,然后會(huì)分配一個(gè)唯一地址削彬。如果不想注冊(cè)的話泣洞,用我的也行:
? ? 在 /etc/docker/daemon.json中刪除原內(nèi)容忧风,加入
{"registry-mirrors": ["https://cugt39s7.mirror.aliyuncs.com"]}
然后執(zhí)行:
? ? sudo systemctl daemon-reload
? ?sudo systemctl restart docker
****注意**** 如果使用公司網(wǎng)絡(luò),而公司網(wǎng)絡(luò)通過(guò)代理上網(wǎng)球凰,則可能不能成功加速狮腿。
需要配置docker代理腿宰,方法如下:
創(chuàng)建目錄:
mkdir -p /etc/systemd/system/docker.service.d
創(chuàng)建文件:
/etc/systemd/system/docker.service.d/http-proxy.conf
在其中加入如下內(nèi)容:
[Service]
Environment="HTTP_PROXY=http://代理ip:代理port" "HTTPS_PROXY=https://代理ip:代理port"
重啟docker服務(wù)
sudo systemctl daemon-reload
sudo systemctl restart docker
5,將當(dāng)前用戶加入docker組缘厢,避免每次docker命令都要sudo
sudo groupadd docker
sudo gpasswd -a $USER docker
退出當(dāng)前用戶(logout)吃度,然后再登錄,就可以直接運(yùn)行 docker xxx 啦
6昧绣,驗(yàn)證安裝:
docker run hello-world
將提示從阿里云下載helloworld鏡像规肴,并運(yùn)行,結(jié)果類似:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.