Ubuntu16.04安装docker
官網:
-
https://docs.docker.com/get-started/
-
https://hub.docker.com/
-
https://docs.docker.com/install/linux/docker-ce/ubuntu/
?
一、安裝
1.?更新
sudo apt-get update
?
2.?安裝依賴包?
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
?
3. 添加官方密鑰
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
?
4. 添加倉庫
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu?$(lsb_release -cs) stable"
?
5. 再次更新
sudo apt-get update
?
6. 安裝docker
sudo apt-get install -y docker-ce
?
?
二、測試
1.? 查看docker服務是否啟動:systemctl status docker
baoli@ubuntu:~$ systemctl status docker ● docker.service - Docker Application Container EngineLoaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)Active: active (running) since Sun 2019-09-08 15:19:27 CST; 44s agoDocs: https://docs.docker.com Main PID: 11480 (dockerd)Tasks: 10Memory: 55.4MCPU: 893msCGroup: /system.slice/docker.service└─11480 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock Sep 08 15:19:26 ubuntu dockerd[11480]: time="2019-09-08T15:19:26.795250717+08:00" level=wa Sep 08 15:19:26 ubuntu dockerd[11480]: time="2019-09-08T15:19:26.795341137+08:00" level=wa Sep 08 15:19:26 ubuntu dockerd[11480]: time="2019-09-08T15:19:26.795349613+08:00" level=wa Sep 08 15:19:26 ubuntu dockerd[11480]: time="2019-09-08T15:19:26.796868238+08:00" level=in Sep 08 15:19:27 ubuntu dockerd[11480]: time="2019-09-08T15:19:27.218386729+08:00" level=in Sep 08 15:19:27 ubuntu dockerd[11480]: time="2019-09-08T15:19:27.438357184+08:00" level=in Sep 08 15:19:27 ubuntu dockerd[11480]: time="2019-09-08T15:19:27.747766312+08:00" level=in Sep 08 15:19:27 ubuntu dockerd[11480]: time="2019-09-08T15:19:27.749026100+08:00" level=in Sep 08 15:19:27 ubuntu systemd[1]: Started Docker Application Container Engine. Sep 08 15:19:27 ubuntu dockerd[11480]: time="2019-09-08T15:19:27.818603590+08:00" level=in lines 1-21/21 (END)若未啟動,則啟動docker: sudo systemctl start docker
?
2.? 運行hello-world
執行:sudo docker run hello-world,提示:
baoli@ubuntu:~$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally docker: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers). See 'docker run --help'.解決:
鑒于國內網絡問題,后續拉取 Docker 鏡像十分緩慢,我們可以需要配置加速器來解決,我使用的是網易的鏡像地址:http://hub-mirror.c.163.com。
1)sudo vim??/etc/docker/daemon.json
2)添加
{ "registry-mirrors": ["http://hub-mirror.c.163.com"] }3)sudo service docker restart
再次執行:sudo docker run hello-world
baoli@ubuntu:~$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:451ce787d12369c5df2a32c85e5a03d52cbcef6eb3586dd03075f3034f10adcd Status: Downloaded newer image for hello-world:latestHello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64) 3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/?
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的Ubuntu16.04安装docker的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux进程和线程
- 下一篇: 网页制作步骤是什么(网站建设制作)