1.首先璃哟,到官網(wǎng)下載 Xenial 內(nèi)核對(duì)應(yīng)的的 deb 包镰矿。
如果需要下載其他 Ubuntu 內(nèi)核版本的 deb 包,可以從此處進(jìn)入下載无拗。
2.安裝 Docker
sudo dpkg -i docker-ce_17.09.1~ce-0~ubuntu_amd64.deb
3.推薦使用阿里云 Docker 加速器
由此鏈接進(jìn)入可申請(qǐng)阿里云專屬的加速器地址笼呆。
申請(qǐng)后執(zhí)行相應(yīng)的命令:
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://yourownkey.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
4.驗(yàn)證 Docker 是否安裝完畢
sudo docker run hello-world
該操作將會(huì)自動(dòng)從官網(wǎng)拉取鏡像并執(zhí)行熊响,如果有如下輸出,說(shuō)明 Docker 安裝成功了诗赌。
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Status: Downloaded newer image for hello-world:latest
Hello 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 the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to 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://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
也可以使用以下命令查看 Docker 是否安裝成功:
sudo docker info
看控制臺(tái)是否有類似如下輸出:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 17.09.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.10.0-28-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.839GiB
Name: charley-virtual-machine
ID: 2RWL:MJ5G:KR4T:PSWT:XVV5:QV6S:YH2K:AFQS:ZUQP:LNJW:SQNO:BVTW
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://2zn744kl.mirror.aliyuncs.com/
Live Restore Enabled: false
WARNING: No swap limit support
5.將當(dāng)前用戶加入到 docker 用戶組中
默認(rèn)情況下汗茄, docker 命令會(huì)使用 Unix socket 與 Docker 引擎通訊。而只有 root 用戶和 docker 組的用戶才可以訪問(wèn) Docker 引擎的 Unix socket铭若。出于安全考慮洪碳,一般 Linux 系統(tǒng)上不會(huì)直接使用 root 用戶。因此叼屠,更好地做法是將需要使用 docker 的用戶加入 docker 用戶組瞳腌。
以上節(jié)選自《Docker技術(shù)入門(mén)與實(shí)戰(zhàn)(第2版)》。
首先確保本機(jī)已存在 docker 用戶組镜雨,如果沒(méi)有可以建立一個(gè):
sudo groupadd docker
然后將當(dāng)前用戶加入到 docker 用戶組:
sudo usermod -aG docker $USER
注銷當(dāng)前用戶再重新登陸嫂侍,就可以在當(dāng)前用戶使用 Docker 了。
6.如果想通過(guò)源而不是 deb 方式進(jìn)行安裝,可以參考附件中的參考資料挑宠。
附:參考資料
Ubuntu 16.04安裝Docker
Ubuntu 16.04 安裝 Docker
完菲盾。