文档章节

ARM64上的Docker编译与安装

openthings
 openthings
发布于 2016/12/08 09:31
字数 1571
阅读 1033
收藏 0

ARM64已经成为手机上的主流,而且开始进入服务器领域(中国的全志、辉腾等芯片也都是ARM架构),很多开发板也相继推出。为了充分发挥其能力,我希望能在上面运行Docker。但是,目前虽然ARM32上面已经有多个Docker移植版本,但是ARM64上找不到现成的(96Boards的系统包含的Docker无法使用),需要自己编译(Docker官网已经包含编译支持)。下面是一些找到的资源,先抓下来,后面再慢慢测试。

在96Board上编译,注意:

  • 烧写最新系统:http://www.96boards.org/documentation/ConsumerEdition/DragonBoard-410c/Installation/LinuxSD.md/
  • 更新源,运行:sudo apt update
  • 安装Docker,运行: sudo apt install docker-engine
  • 让Docker在用户空间运行:sudo usermod -aG docker linaro
  • 1G内存的CE版96Board在编译go时会出现“can't allocate memory”错误,参考这里添加虚存解决:https://my.oschina.net/u/2306127/blog/657269
  • 按照 https://my.oschina.net/u/2306127/blog/801867 中的指南编译Docker新版本。
  • 编译之前不要运行 sudo apt upgrade,因为目前docker源只有1.9.1版本,如果系统其它裤更新到了新版,可能导致Docker无法运行。在编译安装完新版Docker(1.12以后版本)后,再去更新系统。
  • 我按照DieterReuter的方法进行编译(直接在host中编译),后来出现内存分配失败退出。然后直接进入~/home/src/docker里面运行 make deb 编译,这是在docker容器里面编译的。
  • 其它问题,需要修改源码,参考:https://my.oschina.net/u/2306127/blog/803599

首先获取脚本代码:

git clone https://github.com/DieterReuter/arm64-docker-builder.git

下面是来自于DieterReuter的编译指南(是针对Qemu中虚拟机的):

arm64-docker-builder

This repo contains all necessary details and scripts how to compile Docker on an ARM64 (or AARCH64) machine which is running Ubuntu 15.04. This works well, even in a QEMU emulated AARCH64 machine with an Ubuntu 15.04 Cloud Image for ARM64. I've tested all these steps with a QEMU box which could be run with the help of vagrant in VirtualBox or on DigitalOcean with the following repo https://github.com/DieterReuter/qemu-arm-box.

Background

For the last six months or so, I was working hard in my spare time to get Docker running easily for some ARM 32bit systems like the Raspberry Pi. For this year there should be a few new ARM devices coming on the market with 64bit CPUs, and I'd like to get Docker running on these ARM64 devices as soon as possible.

I don't have any ARM64 machine at hand, so I tried to set up a QEMU emulated ARM64 (aka AARCH64) in a reproducible way. I choose Vagrant and created a box running Ubuntu 15.04. With the help of Vagrant it was easy to set up such a box in a local VirtualBox (on my MacBookPro) and also the same way on a DigitalOcean Droplet. I think, now it's easy for everybody to spin up such a QEMU ARM64 box within 5 or 10 minutes on your local machine or in the cloud.

Prerequisites

If you don't have an ARM64 machine at hand like me, you have to create a QEMU box first. This can be done with my repo https://github.com/DieterReuter/qemu-arm-box. Once your ARM64 machine is up and running, just login and go ahead.

Step 1 - install dependencies

First we have to install some development dependencies like Git, Curl, GOLANG and some more specific dependencies for Docker like btrfs, sqlite and devmapper. Please keep in mind, this can take a serious long time on a QEMU emulated machine.

$ ./install-arm64-devtools.sh

Maybe if you run into trouble that the install process gets interrupted while generating a new /boot/initrd.img, you can fix this with the following commands (of course inside the ARM64 machine):

$ sudo dpkg --configure -a --force-depends
$ sudo apt-get install -f

OK, let's skip all these problems for now and just ignore it. For a QEMU machine it could also happens that we have to reboot the machine. At least, we should check, if our dependent packages are already installed:

$ dpkg -l | grep -E "btrfs-tools|libsqlite3-dev|libdevmapper-dev"
ii  btrfs-tools                      3.17-1.1                     arm64        Checksumming Copy on Write Filesystem utilities
ii  libdevmapper-dev:arm64           2:1.02.90-2ubuntu1           arm64        Linux Kernel Device Mapper header files
ii  libsqlite3-dev:arm64             3.8.7.4-1                    arm64        SQLite 3 development files

OK, everything is there. Let's go ahead and compile Docker.

Step 2 - compile the latest version of Docker

The compile script will first clone into the docker/docker repo, so this will take some time. But don't worry for subsequent builds the script just fetches only the latest changes which is much faster. The compile time depends on your host machine and takes around 5 to 20 minutes, the later on a QEMU emulated machine on DigitalOcean; on a local VirtualBox machine it could be faster. And on real hardware you should get the best performance - but who has already an ARM64 power horse at hand?

$ ./compile-docker.sh

Fetch latest changes of docker/docker repository
Previous HEAD position was 7ddecf7... Bump version to v1.7.0
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
Docker version=v1.7.0-rc2
Note: checking out 'v1.7.0-rc2'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at 7ddecf7... Bump version to v1.7.0
# WARNING! I don't seem to be running in the Docker container.
# The result of this command might be an incorrect build, and will not be
#   officially supported.
#
# Try this instead: make all
#

---> Making bundle: dynbinary (in bundles/1.7.0-rc2/dynbinary)
go build: when using gccgo toolchain, please pass linker flags using -gccgoflags, not -ldflags
Created binary: bundles/1.7.0-rc2/dynbinary/dockerinit-1.7.0-rc2
Building: bundles/1.7.0-rc2/dynbinary/docker-1.7.0-rc2
go build: when using gccgo toolchain, please pass linker flags using -gccgoflags, not -ldflags
Created binary: bundles/1.7.0-rc2/dynbinary/docker-1.7.0-rc2

Here are our fresh build artifacts:

$ ls -al bundles/1.7.0-rc2/dynbinary/

total 21052
drwxrwxr-x 2 ubuntu ubuntu     4096 Jun  7 13:13 .
drwxrwxr-x 3 ubuntu ubuntu     4096 Jun  7 12:54 ..
lrwxrwxrwx 1 ubuntu ubuntu       16 Jun  7 13:13 docker -> docker-1.7.0-rc2
-rwxrwxr-x 1 ubuntu ubuntu 17582904 Jun  7 13:13 docker-1.7.0-rc2
-rw-rw-r-- 1 ubuntu ubuntu       51 Jun  7 13:13 docker-1.7.0-rc2.md5
-rw-rw-r-- 1 ubuntu ubuntu       83 Jun  7 13:13 docker-1.7.0-rc2.sha256
lrwxrwxrwx 1 ubuntu ubuntu       20 Jun  7 12:58 dockerinit -> dockerinit-1.7.0-rc2
-rwxrwxr-x 1 ubuntu ubuntu  3945424 Jun  7 12:58 dockerinit-1.7.0-rc2
-rw-rw-r-- 1 ubuntu ubuntu       55 Jun  7 12:58 dockerinit-1.7.0-rc2.md5
-rw-rw-r-- 1 ubuntu ubuntu       87 Jun  7 12:58 dockerinit-1.7.0-rc2.sha256

If you like, you can also build a specific release version of Docker:

$ ./compile-docker.sh 1.7.0-rc1

Step 3 - quickly test the compiled Docker binary

$ ./bundles/1.7.0-rc2/dynbinary/docker-1.7.0-rc2 version

Client version: 1.7.0-rc2
Client API version: 1.19
Go version (client): go1.4.2 gccgo (Ubuntu 5.1~rc1-0ubuntu1) 5.0.1 20150414 (prerelease) [gcc-5-branch revision 222102]
Git commit (client): 7ddecf7
OS/Arch (client): linux/arm64
Get http:///var/run/docker.sock/v1.19/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?

Success, it runs in client mode and the arch type is linux/arm64.

Further steps

The next steps should be to get the Docker engine running in daemon mode on the ARM64 machine. But I think, this will take some more time to adjust the appropriate kernel options, include all needed kernel modules like Overlay filesystem and so on. And maybe also a serious amount of testing and possibly setting up a completely automated build server for compiling and testing Docker on ARM64 machines. This should get even better as soon as we have some real hardware to speed up the dev-test cycles.

Have fun to use this tutorial as a starting point, and please share your experience with me.

© 著作权归作者所有

共有 人打赏支持
openthings
粉丝 277
博文 1027
码字总数 557983
作品 1
东城
架构师
私信 提问
96Boards(410C)中的Docker使用方法

ARM64已经成为手机上的主流,而且开始进入服务器领域(中国的全志、辉腾等芯片也都是ARM架构),很多开发板也相继推出。为了充分发挥其能力,我希望能在上面运行Docker。但是,目前虽然ARM32...

openthings
2016/12/09
129
0
[NodeJS for Android]完美编译大全

NodeJS for Android完美编译大全 完美地编译了NodeJS for android-{arm,arm64,x86,x64,mipsel},并且提供预编译版,和作为持续编译环境的Docker image。 完美, 意思是不去掉任何功能(不加选项)...

Q_J
2016/09/08
143
0
ARM64上Docker编译问题与解决

编译过程 在96Boards 的410C上编译Docker(这里使用Dokcer 1.14 Master版本,方法参考),遇到些问题,解决方法如下: 修改Docker源码目录下的Dockerfile.aarch64文件 修改 FROM aarch64/ubu...

openthings
2016/12/10
44
0
做了个工具android-gcc-toolchain方便使用NDK

自从第一次用NDK时写了拒绝ndk-build,过了两年了,也没有看到自己想要的工具,忍不了了,就想着有时间时写一个,就是写bash而已,不过我对bash不熟,磕磕碰碰花了不少时间,汗。(2016/09/08...

Q_J
2016/08/11
103
0
从零开始手敲次世代游戏引擎(Android特别篇)-1

本篇开始我们将我们开发的引擎移植到Android上面去。 首先我们需要构建Android的开发环境。无论是基于Windows的Visual Studio,还是基于mac OS的XCode,亦或是基于java的Eclipse,以及googl...

陈文礼
01/08
0
0

没有更多内容

加载失败,请刷新页面

加载更多

开源软件会被云杀死吗 ?

本文转载云头条,原作者:Michael Stiefel是Reliable Software公司的负责人,是一名软件架构和开发顾问。 文章要点 虽然开源开发不会消失,但商业开源厂商的未来不是很有希望。随着全面管理的...

linuxCool
40分钟前
4
0
OSChina 周三乱弹 —— 谈什么对象?睡什么觉?

Osc乱弹歌单(2018)请戳(这里) 【今日歌曲】 @胖达panda :最肯忘却古人诗,最不屑一顾是相思。分享童丽的单曲《红豆生南国》: 《红豆生南国》- 童丽 手机党少年们想听歌,请使劲儿戳(这...

小小编辑
44分钟前
237
5
stylus

stylus基础教程,stylus实例教程,stylus语法总结

miaojiangmin
今天
5
0
PHP生成CSV之内部换行

当我们使用PHP将采集到的文件内容保存到csv文件时,往往需要将采集内容进行二次过滤处理才能得到需要的内容。比如网页中的换行符,空格符等等。 对于空格等处理起来都比较简单,这里我们单独...

豆花饭烧土豆
今天
2
0
使用 mjml 生成 thymeleaf 邮件框架模板

发邮件算是系统开发的一个基本需求了,不过搞邮件模板实在是件恶心事,估计搞过的同仁都有体会。 得支持多种客户端 支持响应式 疼彻心扉的 outlook 多数客户端只支持 inline 形式的 css 布局...

郁也风
今天
10
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部