Oracle CloudのA1.Flexのように、aarch64/arm64のアーキテクチャへのDocker本体のインストールは以下のとおり公式の手順で(ディストリビューションが対応してれば)インストールできる。
ただし、Docker Composeについては公式で配布されてるバイナリはamd64しかないため、公式の手順通りにインストールしてもarm64上のホストだと実行できない (※ 9/29追記: Docker Compose v2になってarm64版も公開されるようになっており、Docker Pluginとして利用可能) 。
「Cloud Integrations」とされてるこちらのComposeだとarm64版も配布されてて試した限り動かせそうだけど、コマンド体系が微妙に違う?(詳細よくわからず)
使い慣れてるのDocker Composeをarm64のホストにインストールするには、pipでインストールするのが簡単そうだったので試してみた。
ドキュメントの「Install Compose」->「Alternative install options」->「Install using pip」を参照。
公式ではvirtualenv推奨となってるけど本エントリではとりあえずsudoでシステムワイドに入れてる。
環境はOracle Cloudの無償枠A1.FlexのVMを使用。
Ubuntu 20.04
pipはデフォルトでは入ってないのでaptでインストールする。
$ sudo apt-get install python3-pip
$ sudo pip install docker-compose
sudoつけてpipで入れると/usr/local/bin/docker-composeにインストールされる。
venvで環境分けた場合に以下のエラーが出るのであれば、venv作成時に--system-site-packagesつけておけばよいかも。
error: invalid command 'bdist_wheel' ---------------------------------------- ERROR: Failed building wheel for docopt
$ docker-compose version docker-compose version 1.29.2, build unknown docker-py version: 5.0.2 CPython version: 3.8.10 OpenSSL version: OpenSSL 1.1.1f 31 Mar 2020
サンプル実行。Compose Fileはこんな感じ。
version: '3' services: httpd: image: httpd ports: - 8080:80
$ docker-compose up -d
Creating network "compose_default" with the default driver
Pulling httpd (httpd:)...
latest: Pulling from library/httpd
d10c227306ce: Pull complete
11d295310975: Pull complete
0bd1854e47c1: Pull complete
f7ee7d85565b: Pull complete
6f13eaecb486: Pull complete
Digest: sha256:ead5178e79caa09343750bb03ff98e87ed57c537f2ae12685beb3a573cce8f55
Status: Downloaded newer image for httpd:latest
Creating compose_httpd_1 ... done
$ docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------
compose_httpd_1 httpd-foreground Up 0.0.0.0:8080->80/tcp,:::8080->80/tcp
$ curl localhost:8080
<html><body><h1>It works!</h1></body></html>
Oracle Linux 8/7.9
Oracle Linuxの場合は8も7.9も手順は同じ。
pip3は始めから使用できる。
$ sudo pip3 install docker-compose
次のエラーが出る場合は…
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-_2zf4o3l/pynacl/
Building wheels for collected packages: pynacl, pyrsistent Building wheel for pynacl (PEP 517) ... error
build/temp.linux-aarch64-3.6/_sodium.c:22:12: fatal error: pyconfig.h: No such file or directory
# include <pyconfig.h>
^~~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pynacl
この場合はdevel系のパッケージを追加して再度pipインストールする。
$ sudo dnf install python3-devel
インストールできればこの通り。サンプルはUbuntuの時と同じもの。
$ docker-compose up -d Creating network "compose_default" with the default driver Pulling httpd (httpd:)... latest: Pulling from library/httpd d10c227306ce: Pull complete 11d295310975: Pull complete 0bd1854e47c1: Pull complete f7ee7d85565b: Pull complete 6f13eaecb486: Pull complete Digest: sha256:ead5178e79caa09343750bb03ff98e87ed57c537f2ae12685beb3a573cce8f55 Status: Downloaded newer image for httpd:latest Creating compose_httpd_1 ... done
$ curl localhost:8080 <html><body><h1>It works!</h1></body></html>