安裝步驟:
- 使用管理員帳號登錄ubuntu 15.04系統(tǒng),保證該管理有root權(quán)限,或者可以執(zhí)行sudo命令。
- 檢查curl包有沒有安裝。
which curl
如果curl沒有安裝的話,更新apt源之后,安裝curl包。
sudo apt-get update $ sudo apt-get install curl
- 獲得最新的docker安裝包。
curl -sSL https://get.docker.com/ | sh
shell會提示你輸入sudo的密碼,然后開始執(zhí)行安裝過程。
- 確認Docker是否安裝成功。
sudo docker run hello-world
這個命令會下載一個測試用的鏡像并啟動一個容器運行它。
或者,用 docker info 命令應(yīng)該能夠確認 Docker 是否已經(jīng)正常安裝并運行了:
sudo docker info
可能遇到的問題:
問題1:
由于國內(nèi)網(wǎng)絡(luò)原因,第四步可能會報錯
root@2560p:~# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pulling fs layer
docker: error pulling image configuration: Get https://registry-1.docker.io/v2/library/hello-world/blobs/sha256:48b5124b2768d2b917edcb640435044a97967015485e812545546cbed5cf0233: read tcp 192.168.2.112:46466->50.17.62.194:443: read: connection reset by peer.
See 'docker run --help'.
解決方法:
注冊并使用DaoCloud的加速器:https://www.daocloud.io/mirror#accelerator-doc
會給每個用戶分配一個加速網(wǎng)址
修改文件:
vi /etc/default/docker
添加如下這段話:(xxxxxxx為分配給你的id)
DOCKER_OPTS="--registry-mirror=http://xxxxxxxx.m.daocloud.io"
重啟docker:
service docker restart
問題2:
在Ubuntu中,如果使用UFW,需要修改/etc/default/ufw 文件:
DEFAULT_FORWARD_POLICY="ACCEPT"
保存修改內(nèi)容并重新加載 UFW:
sudo ufw reload