您好,登錄后才能下訂單哦!
這篇文章主要介紹樹莓派2下如何安裝docker,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
以前一直不清楚所謂的 Docker容器
是什么, 偶爾看一些相關的信息, 也是看得云里霧里. 不過轉機在昨天出現, 昨晚看了幾篇非常不錯的 docker
資料, 才明白, 原來就是一個輕量級的類似虛擬機的東東.
它可以從你的系統中隔離出一個空間, 在這個隔離空間中你可以安裝/配置/運行各種軟件, 而不會對你原有的系統造成影響.
而且你安裝配置好的一切都可以導出一個單獨的鏡像文件, 以后你想回到自己之前配置好的環境作業, 直接導入這個鏡像文件就行了(感覺跟 Common Lisp
運行時鏡像的概念很相似). docker
具備類似 Git
的版本管理功能, 這樣每次對環境的更改都會被記錄, 你可以很方便地回退到任何一個改動點.
你生成的鏡像文件也可以共享給其他人使用, 這對于多人開發的項目很有用, 可以把開發環境配置的工作一次搞定. 其實 docker
更大的用途是運行配置好的應用.
那么就試著安裝一下吧, 按照說明, 直接在我的兩個樹莓派2(一個安裝了Raspbian
系統, 一個安裝了 Kano
系統)下運行命令:
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 ~ $
很好, 提示我已經安裝了最新的版本, 那就運行一下吧:
pi@rpi ~ $ sudo docker --help sudo: docker: command not found pi@rpi ~ $
奇怪了, 說是找不到命令, 那就看看安裝到哪里去了:
pi@rpi ~ $ whereis docker docker: pi@rpi ~ $
好像有些不大對頭, 貌似沒有找到關于 docker
的可執行文件, 而我們用 whereis
命令查找 git
和 tmux
的輸出如下:
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
搜索一下:
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
為名的軟件:
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 ~ $
原來是這樣, docker
跟 raspbian
系統下的一個系統托盤應用重名了, 我們要找的容器 docker
是 docker.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)
以上是“樹莓派2下如何安裝docker”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。