GW102网关的Ubuntu系统使用Docker虚拟化容器
现代的嵌入式产品开发中,业务应用的开发语言和方式有各种各样,不同的开发语言需要相应的开发环境才可以正确运行。虚拟化容器技术出现提升了各类语言的开发和部署的便捷性,Linux下最常用的虚拟化容器技术就是Docker了。下面我们在GW102网关上来演示如何使用Docker容器。
GW102和GW101网关是基于NXP i.MX6ULL芯片平台,虽然只有单核800Mhz的主频,但是依然可以运行Docker虚拟化服务。这里我们选择在Ubuntu系统下使用Docker功能。默认的Linux kernel配置并不支持Docker需要的功能,所以我们启用了一些必须的配置后,系统就可以支持Docker功能了。
启动Ubuntu系统后,我们添加docker的软件源,就可以通过apt命令来安装docker软件了。
deb [arch=armhf] https://download.docker.com/linux/ubuntu bionic stable
安装好docker后,`添加当前用户到docker用户组,就不用每次都需要使用sudo命令了。
usermode -a -G docker i2som
查看docker的版本
i2som@gw102:~$ docker version
Client: Docker Engine - Community
Version: 20.10.17
API version: 1.41
Go version: go1.17.11
Git commit: 100c701
Built: Mon Jun 6 23:03:25 2022
OS/Arch: linux/arm
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.17.11
Git commit: a89b842
Built: Mon Jun 6 23:01:25 2022
OS/Arch: linux/arm
Experimental: false
containerd:
Version: 1.6.8
GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
runc:
Version: 1.1.4
GitCommit: v1.1.4-0-g5fd4c4d
docker-init:
Version: 0.19.0
GitCommit: de40ad0
测试运行hello-world镜像
i2som@gw102:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9b157615502d: Already exists
Digest: sha256:7d246653d0511db2a6b2e0436cfd0e52ac8c066000264b3ce63331ac66dca625
Status: Downloaded newer image for hello-world:latest
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.
(arm32v7)
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 ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
到此,我们的docker服务基本上安装并验证是正常的,后续我们就可以把应用通过docker来部署,达到应用环境与系统环境隔离的目的。