温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

树莓派2下如何安装docker

发布时间:2021-11-12 14:35:50 来源:亿速云 阅读:229 作者:小新 栏目:云计算

这篇文章主要介绍树莓派2下如何安装docker,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

树莓派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 命令查找 gittmux 的输出如下:

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 ~ $

原来是这样, 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)

以上是“树莓派2下如何安装docker”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI