樹莓派2下安裝 docker 記錄

樹莓派2下安裝 docker 記錄

之前一直不清楚所謂的 Docker容器 是什麼, 偶爾看一些相關的信息, 也是看得雲裏霧裏. 不過起色在昨天出現, 昨晚看了幾篇很是不錯的 docker 資料, 才明白, 原來就是一個輕量級的相似虛擬機的東東.python

它能夠從你的系統中隔離出一個空間, 在這個隔離空間中你能夠安裝/配置/運行各類軟件, 而不會對你原有的系統形成影響.git

並且你安裝配置好的一切均可以導出一個單獨的鏡像文件, 之後你想回到本身以前配置好的環境做業, 直接導入這個鏡像文件就好了(感受跟 Common Lisp 運行時鏡像的概念很類似). docker 具有相似 Git 的版本管理功能, 這樣每次對環境的更改都會被記錄, 你能夠很方便地回退到任何一個改動點.github

你生成的鏡像文件也能夠共享給其餘人使用, 這對於多人開發的項目頗有用, 能夠把開發環境配置的工做一次搞定. 其實 docker 更大的用途是運行配置好的應用.golang

那麼就試着安裝一下吧, 按照說明, 直接在個人兩個樹莓派2(一個安裝了Raspbian 系統, 一個安裝了 Kano 系統)下運行命令:web

pi@rpi ~ $ sudo apt-get install docker
Reading package lists... Done
Building dependency tree
Reading state information... Done
docker is already the newest version.
The following packages were automatically installed and are no longer required:
  libmozjs10d libopencc1 libpresage-data libpresage1 libproxy0 libtinyxml2.6.2 libwebp2 presage python-support realpath
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 106 not upgraded.
pi@rpi ~ $

很好, 提示我已經安裝了最新的版本, 那就運行一下吧:docker

pi@rpi ~ $ sudo docker --help
sudo: docker: command not found
pi@rpi ~ $

奇怪了, 說是找不到命令, 那就看看安裝到哪裏去了:bootstrap

pi@rpi ~ $ whereis docker
docker:
pi@rpi ~ $

好像有些不大對頭, 貌似沒有找到關於 docker 的可執行文件, 而咱們用 whereis 命令查找 gittmux 的輸出以下:vim

pi@rpi ~ $ whereis git
git: /usr/bin/git /usr/share/man/man1/git.1.gz
pi@rpi ~ $ whereis tmux
tmux: /usr/bin/tmux /usr/local/bin/tmux /usr/share/man/man1/tmux.1.gz
pi@rpi ~ $

那麼用 find 搜索一下:api

pi@rpi ~ $ sudo find / -name docker
/opt/github/buildroot/package/docker
/usr/share/doc/docker
/usr/share/menu/docker
pi@rpi ~ $

違和感更強烈了, 上面這幾個好像看起來都不大象是一個獨立的軟件包的樣子, 那麼咱們用 apt-cache search 命令看看是否還有其餘以 docker 爲名的軟件:ruby

pi@rpi ~ $ sudo apt-cache search docker
docker - System tray for KDE3/GNOME2 docklet applications
karbon - vector graphics application for the Calligra Suite
kdocker - lets you dock any application into the system tray
docker.io - Linux container runtime
golang-docker-dev - Externally reusable Go packages included with Docker
python-docker - Python wrapper to access docker.io's control socket
python3-docker - Python 3 wrapper to access docker.io's control socket
ruby-docker-api - Ruby gem to interact with docker.io remote API
vim-syntax-docker - Docker container engine - Vim highlighting syntax files
pi@rpi ~ $

原來是這樣, dockerraspbian 系統下的一個系統托盤應用重名了, 咱們要找的容器 dockerdocker.io, 那麼試着安裝一下:

pi@rpi ~ $ sudo apt-get install docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libmozjs10d libopencc1 libpresage-data libpresage1 libproxy0 libtinyxml2.6.2 libwebp2 presage python-support realpath
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  aufs-tools cgroupfs-mount libapparmor1
Suggested packages:
  btrfs-tools debootstrap lxc rinse
The following NEW packages will be installed:
  aufs-tools cgroupfs-mount docker.io libapparmor1
0 upgraded, 4 newly installed, 0 to remove and 106 not upgraded.
Need to get 3,235 kB of archives.
After this operation, 15.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main cgroupfs-mount all 1.1 [4,572 B]
Get:2 http://mirrordirector.raspbian.org/raspbian/ jessie/main aufs-tools armhf 1:3.2+20130722-1.1 [91.0 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ jessie/main libapparmor1 armhf 2.9.0-3 [58.1 kB]
Get:4 http://mirrordirector.raspbian.org/raspbian/ jessie/main docker.io armhf 1.3.3~dfsg1-2 [3,082 kB]
Fetched 3,235 kB in 15s (209 kB/s)
Selecting previously unselected package aufs-tools.
(Reading database ... 188303 files and directories currently installed.)
Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1_armhf.deb ...
Unpacking aufs-tools (1:3.2+20130722-1.1) ...
Selecting previously unselected package cgroupfs-mount.
Preparing to unpack .../cgroupfs-mount_1.1_all.deb ...
Unpacking cgroupfs-mount (1.1) ...
Selecting previously unselected package libapparmor1:armhf.
Preparing to unpack .../libapparmor1_2.9.0-3_armhf.deb ...
Unpacking libapparmor1:armhf (2.9.0-3) ...
Selecting previously unselected package docker.io.
Preparing to unpack .../docker.io_1.3.3~dfsg1-2_armhf.deb ...
Unpacking docker.io (1.3.3~dfsg1-2) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for systemd (215-17+deb8u2) ...
Setting up aufs-tools (1:3.2+20130722-1.1) ...
Setting up cgroupfs-mount (1.1) ...
Mounting cgroupfs hierarchy.
Setting up libapparmor1:armhf (2.9.0-3) ...
Setting up docker.io (1.3.3~dfsg1-2) ...
Adding group `docker' (GID 117) ...
Done.
Starting Docker: docker.
Processing triggers for libc-bin (2.19-18+deb8u1) ...
Processing triggers for systemd (215-17+deb8u2) ...
pi@rpi ~ $

果真如此, 順利安裝完畢, 試着運行一下:

pi@rpi ~ $ docker --version
Docker version 1.3.3, build d344625
pi@rpi ~ $
pi@rpi ~ $ sudo docker info
Containers: 0
Images: 0
Storage Driver: devicemapper
 Pool Name: docker-179:2-73614-pool
 Pool Blocksize: 65.54 kB
 Data file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 305.7 MB
 Data Space Total: 107.4 GB
 Metadata Space Used: 729.1 kB
 Metadata Space Total: 2.147 GB
 Library Version: 1.02.90 (2014-09-01)
Execution Driver: native-0.2
Kernel Version: 4.1.13-v7+
Operating System: Raspbian GNU/Linux 8 (jessie)
WARNING: No swap limit support
pi@rpi ~ $

很好, 如今咱們已經成功地在 raspbian 系統上安裝了一個 docker, 後續就能夠在這個 docker 進行操做了.

啓動咱們的 docker 守護進程:

pi@rpi ~/notebooks $ sudo docker -d
2015/12/29 16:35:03 docker daemon: 1.3.3 d344625; execdriver: native; graphdriver: 
[ed7f66b0] +job serveapi(unix:///var/run/docker.sock)
WARNING: The Docker runtime currently only officially supports amd64 (not arm). THIS BUILD IS NOT OFFICIAL AND WILL NOT BE SUPPORTED BY DOCKER UPSTREAM.[info] Listening for HTTP on unix (/var/run/docker.sock)
[ed7f66b0] +job init_networkdriver()
Interface docker0 has more than 1 IPv4 address. Defaulting to using 172.17.42.1
[ed7f66b0] -job init_networkdriver() = OK (0)
2015/12/29 16:35:04 WARNING: Your kernel does not support cgroup swap limit.
[info] Loading containers: 
[info] : done.
[ed7f66b0] +job acceptconnections()
[ed7f66b0] -job acceptconnections() = OK (0)

--結束

相關文章
相關標籤/搜索