安裝 Docker 非常簡單错敢。任何一門編程語言秸讹,我們都是從 Hello World 開始该溯,這里,我們的首要目標(biāo)就是先把 Docker 跑起來绅络。下面以 Ubuntu 為例看看我們是如何把 Docker 跑起來的月培。
安裝
Ubuntu 下安裝 Docker 執(zhí)行:
sudo apt-get install docker.io
安裝后嘁字,執(zhí)行 docker version
查看版本:
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.4
Git commit: e68fc7a
Built: Wed Sep 26 01:43:33 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.4
Git commit: e68fc7a
Built: Mon Sep 24 22:42:19 2018
OS/Arch: linux/amd64
Experimental: false
如果出現(xiàn)權(quán)限出錯(cuò)的問題,執(zhí)行 sudo docker version
杉畜。下面就讓 Docker 跑起來吧:
docker run --name hello hello-world
上面這句話的意思是啟動(dòng)一個(gè)名為 hello 的容器纪蜒,該容器用到的鏡像是 hello-world,當(dāng)本地沒有該竟像時(shí)此叠,會(huì)先從 Docker 官方倉庫下載該鏡像到本地纯续,然后啟動(dòng)。不出意外會(huì)打印一下信息:
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://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
假如灭袁,這里出現(xiàn)權(quán)限問題猬错,仍然以 sudo 身份運(yùn)行。如果相以當(dāng)前登陸的用戶運(yùn)行 Docker 而不想在 run 一個(gè)容器時(shí)前面加上 sudo茸歧,可以通過一下辦法來解決:
sudo gpasswd -a ${USER} docker # 將當(dāng)前用戶加入 Docker 用戶組
sudo systemctl restart docker # 重啟 Docker 服務(wù)
執(zhí)行完畢以后倦炒,要重啟計(jì)算機(jī)哦。至此举娩,便順利地把 Docker 安裝上了析校, Happy Dockering