於 Ubuntu 14.04 安裝 Docker 1.9.1+

Docker 是近幾年來很火紅的開放源始碼虛擬技術,雖說 Ubuntu 14.04 已有內建 Docker,但 v1.6.3 的 docker.io 似乎對私有的 (private) docker-regisrty 有些不相容,凍仁在此附上 Docker v1.9.1 的裝法。

圖片來源:Aurora Solutions

1. 新增 apt key。
[ jonny@trusty ~ ]
$ sudo apt-key adv \
    --keyserver hkp://p80.pool.sks-keyservers.net:80 \
    --recv-keys 58118E89F3A912897C070ADBF76221572C52609D [Enter]

2. 新增套件來源。
[ jonny@trusty ~ ]
$ sudo su -c 'cat >> /etc/apt/sources.list.d/docker.list <<EOF
deb https://apt.dockerproject.org/repo ubuntu-trusty main
EOF' [Enter]

3. 更新套件來源。
[ jonny@trusty ~ ]
$ sudo aptitude update [Enter]

4. 安裝 Docker。
[ jonny@trusty ~ ]
$ sudo aptitude install -y docker-engine [Enter]

5. 檢查 Docker 版本。
[ jonny@trusty ~ ]
$ sudo docker --version [Enter]
Docker version 1.9.1, build a34a1d5

6. 將當前使用者加入 Docker 使用者群組,這樣使用 docker 相關指令時才不需一直搭 sudo 用,需要重新登入後才會生效。(選項)
[ jonny@trusty ~ ]
$ sudo usermod -aG docker ${USER} [Enter]

7. 執行 hello-world 看 Docker 是否可以正常運作。
[ jonny@trusty ~ ]
$ sudo docker run hello-world [Enter]
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.
 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 Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

Docker 已經是 DevOps 之路必修的技能之一,就算只是用來測試、除錯 Linux 的環境也非常之好用,若不排斥命令列 (Command Line),相信可以在 Docker 裡找到不少樂趣。

2016-04-13


因應 Docker 近日頻繁的 release,故將文章標題從「於 Ubuntu 14.04 安裝 Docker 1.9.1」更名為「於 Ubuntu 14.04 安裝 Docker 1.9.1+」。

相關連結:
Installation on Debian | Docker.com
Installation on Mac OS X | Docker.com
Installation on Windows | Docker.com
《Docker —— 從入門到實踐­》正體中文版 - GitBook
命令列的藝術 (the-art-of-command-line) | GitHub

資料來源:
Installation on Ubuntu | Docker.com

留言

Popular Articles

MySQL 語法匯整