Raspberries come in the installation and use of Docker
Docker is an open source application container engine that allows developers to package their applications and dependencies to a lightweight, portable container and then posted to any popular Linux machine, can be virtualized. The container is full use of the sandbox mechanism will not have any interface, vessel performance with very low overhead between each other. This is useful for Raspberry Pi, this tutorial will introduce this tool and how to install Docker Docker on Raspbian.
Docker application scenarios
Automation package and publish Web applications.
Automated testing and continuous integration, release.
Deployment and tuning the database or other back-office applications in a service-oriented environment.
Recompile or extend an existing OpenShift or Cloud Foundry PaaS platform to build their own environment.
Docker's advantage
Docker allows developers to package their applications as well as a portable container to the dependencies, and then posted to any popular Linux machine, you can virtualize. Convenient Docker already is the biggest advantage of, used to take days or even weeks with the task in handling Docker containers, only take seconds to complete. Docker can simplify the deployment of multiple application instances work. Such as Web applications, back-end applications, database applications, large data applications such as Hadoop cluster, message queues, etc., can be packaged into a single image deployment.
Here are two methods for installing Docker, the simplest is to download directly from get.docker.com installation script and start the installation. Only execute the following line command. After testing, raspberry pie 3B, 3A +, 3B + can support Docker, raspberry pie Zero Although you can install successfully, but can not start Docker service .
Installation method (installation script)
Script installation is the most recommended way, just type the following command, wait for the automatic installation can be good.
1
|
sudo
curl -sSL https:
//get
.docker.com | sh
|
If this step is successful installation, you can jump directly below the graphical installer where to continue reading.
The method of mounting two (apt installed)
由于 Raspbian 基于 Debian,我们还可以使用 apt 来安装 Docker,首先需要更新一下软件包的索引。
1
|
sudo
apt-get update
|
安装 HTTPS 所依赖的包
1
2
3
|
sudo
apt-get
install
apt-transport-https \
ca-certificates \
software-properties-common
|
添加 Docker 的 GPG key
1
|
curl -fsSL https:
//yum
.dockerproject.org
/gpg
|
sudo
apt-key add -
|
验证 key id:
1
|
apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D
|
设置稳定的 repository:
1
2
3
4
|
sudo
add-apt-repository \
"deb https:
//apt
.dockerproject.org
/repo/
\
raspbian-$(lsb_release -cs) \
main"
|
注意:如果 add-apt-repository 命令遇到问题,可以尝试将下面这行添加到树莓派软件源 sources.list,操作如下:
1
|
sudo
nano
/etc/apt/sources
.list
|
添加一行:
deb https://apt.dockerproject.org/repo/ raspbian-RELEASE main
根据自己系统版本调整上面的 RELEASE。通过下面的命令可以查看发行版。
1
|
lsb_release -cs
|
安装 Docker
1
2
|
sudo
apt-get update
sudo
apt-get -y
install
docker-engine
|
测试 Docker
运行 hello-world 镜像来做一个测试。
1
|
sudo
docker run hello-world
|
如果 Docker 安装成功,你会看到一条消息:“Hello from Docker!”。
常用配置和工具命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#查看 Docker 版本
docker -
v
sudo
docker pull 仓库/镜像:版本(留空的话默认为 latest)
sudo
docker run 加参数,用来创建容器
#查看运行容器
sudo
docker
ps
#查看所有下载的镜像
sudo
docker images
#进入容器终端
sudo
docker
exec
-i -t ha
/bin/bash
#实时查看10行的 ha 日志
sudo
docker logs -f -t --
tail
10 ha
#重启 systemctl 守护进程
sudo
systemctl daemon-reload
#设置 Docker 开机启动
sudo
systemctl
enable
docker
#开启 Docker 服务
sudo
systemctl start docker
#下载 Docker 图形化界面 portainer
sudo
docker pull portainer
/portainer
#创建 portainer 容器
sudo
docker volume create portainer_data
#运行 portainer
sudo
docker run -d -p 9000:9000 --name portainer --restart always -
v
/var/run/docker
.sock:
/var/run/docker
.sock -
v
portainer_data:
/data
portainer
/portainer
|
在图形化界面中操作更加便利。运行之后在浏览器中输入树莓派IP:9000 进入界面。
首次访问需要设定登录密码。
对于树莓派上的应用,选择 Local 就好。
在控制台可以看到 Docker 的各种资源信息。
from: http://shumeipai.nxez.com/2019/05/20/how-to-install-docker-on-your-raspberry-pi.html