Ubuntu16.04 Docker 安装
生活随笔
收集整理的這篇文章主要介紹了
Ubuntu16.04 Docker 安装
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
前提條件
Docker 要求 Ubuntu 系統的內核版本高于 3.10 ,查看本頁面的前提條件來驗證你的 Ubuntu 版本是否支持 Docker。
通過 uname -r 命令查看你當前的內核版本
使用腳本安裝Docker
root@ranxf:/home/ranxf# wget -qO- https://get.docker.com/ | sh下載腳本并且安裝Docker及依賴包
root@ranxf:/home/ranxf# wget -qO- https://get.docker.com/ | sh # Executing docker install script, commit: 92d5116 + sh -c apt-get update -qq >/dev/null + sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null + sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - >/dev/null + sh -c echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge" > /etc/apt/sources.list.d/docker.list + [ ubuntu = debian ] + sh -c apt-get update -qq >/dev/null + sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null?
+ sh -c docker version Client:Version: 18.04.0-ceAPI version: 1.37Go version: go1.9.4Git commit: 3d479c0Built: Tue Apr 10 18:20:32 2018OS/Arch: linux/amd64Experimental: falseOrchestrator: swarmServer:Engine:Version: 18.04.0-ceAPI version: 1.37 (minimum version 1.12)Go version: go1.9.4Git commit: 3d479c0Built: Tue Apr 10 18:18:40 2018OS/Arch: linux/amd64Experimental: false If you would like to use Docker as a non-root user, you should now consider adding your user to the "docker" group with something like:sudo usermod -aG docker your-userRemember that you will have to log out and back in for this to take effect!安裝完成后有個提示:當要以非root用戶可以直接運行docker時,需要執行 sudo usermod -aG docker runoob 命令,然后重新登陸
WARNING: Adding a user to the "docker" group will grant the ability to runcontainers which can be used to obtain root privileges on thedocker host.Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surfacefor more information.2、啟動docker 后臺服務
root@ranxf:/home/ranxf# service docker start root@ranxf:/home/ranxf# root@ranxf:/home/ranxf# ps -ef |grep docker root 474 1 0 14:28 ? 00:00:01 /usr/bin/dockerd -H fd:// root 481 474 0 14:28 ? 00:00:01 docker-containerd --config /var/run/docker/containerd/containerd.toml root 2103 18769 0 14:41 pts/12 00:00:00 grep --color=auto docker root@ranxf:/home/ranxf#3、測試運行hello-world
root@ranxf:/home/ranxf# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 9bb5a5d4561a: Pull complete Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77 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 bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/engine/userguide/你可能想核對一下 docker 版本:
root@ranxf:/home/ranxf# docker version Client:Version: 18.04.0-ceAPI version: 1.37Go version: go1.9.4Git commit: 3d479c0Built: Tue Apr 10 18:20:32 2018OS/Arch: linux/amd64Experimental: falseOrchestrator: swarmServer:Engine:Version: 18.04.0-ceAPI version: 1.37 (minimum version 1.12)Go version: go1.9.4Git commit: 3d479c0Built: Tue Apr 10 18:18:40 2018OS/Arch: linux/amd64Experimental: false現在,docker 已經安裝在您的系統上。
鏡像加速:
如果要配置 Docker 守護進程默認使用 Docker 官方鏡像加速。可以在 Docker 守護進程啟動時配置 --registry-mirror 參數。
通過命令行啟動Docker
docker --registry-mirror=https://registry.docker-cn.com daemon通過配置文件啟動Docker
Docker 版本在 1.12 或更高
修改 /etc/docker/daemon.json 文件并添加上 registry-mirrors 鍵值(沒有該文件的話,請先建一個)。
鑒于國內網絡問題,后續拉取 Docker 鏡像十分緩慢,我們可以需要配置加速器來解決,如:網易的鏡像地址
{"registry-mirrors":["http://hub-mirror.c.163.com"] }?
從 Docker 庫先下載 Docker Image 制作的容器。
root@ranxf:/home/ranxf# docker run ubuntu:15.10 /bin/echo "Hello world" Unable to find image 'ubuntu:15.10' locally 15.10: Pulling from library/ubuntu 7dcf5a444392: Downloading [====================================> ] 37.63MB/51.07MB 759aa75f3cee: Download complete 7dcf5a444392: Pull complete 759aa75f3cee: Pull complete 3fa871dc8a2b: Pull complete 224c42ae46e7: Pull complete Digest: sha256:02521a2d079595241c6793b2044f02eecf294034f31d6e235ac4b2b54ffc41f3 Status: Downloaded newer image for ubuntu:15.10?
轉載于:https://www.cnblogs.com/ranxf/p/8867553.html
總結
以上是生活随笔為你收集整理的Ubuntu16.04 Docker 安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 字符串转二维数组
- 下一篇: 201571030335/2015710