Raspberry PiのDocker環境でAlpine Linuxイメージ(3.13以降)を使用する際の注意点

3 min read読了の目安(約3300字


  • Raspberry PiのDocker環境で最新のAlpine Linuxイメージを使用しようとしたところ問題が発生
  • コンテナを正常に使用できるようにしたところまでの情報を残しておく


  • Raspberry Pi 2 Model B Rev 1.2
    • Raspberry Pi OS Lite(32bit) - January 11th 2021
    • Docker 20.10.4
  • Docker Image
    • alpine:latest (as 3.13.2)


apk updateに失敗する

$ docker run -it alpine:latest sh
/ # apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/armhf/APKINDEX.tar.gz
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.13/main: temporary error (try again later)
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: No such file or directory
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/armhf/APKINDEX.tar.gz
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.13/community: temporary error (try again later)
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/community: No such file or directory
2 errors; 14 distinct packages available


/ # date
Sun Jan  0 00:100:33238  1900

Alpine Linuxの公式に書いてあった

musl 1.2

musl has been upgraded to 1.2. This release changes the definition of time_t on 32-bit systems. See the musl time64 release notes for more details.

time64 requirements

The following important information applies for users of x86, armv7, and armhf (currently supported 32-bit architectures), including 32-bit Docker containers on 64-bit hosts.


In order to run under old Docker or libseccomp versions, the moby default seccomp profile should be downloaded and on line 2, defaultAction changed to SCMP_ACT_TRACE, then --seccomp-profile=default.json can be passed to dockerd, or --security-opt=seccomp=default.json passed to docker create or docker run. This will cause the system calls to return ENOSYS instead of EPERM, allowing the container to fall back to 32-bit time system calls. In this case, the container will not be compatible with dates past 2038.

Alternatively, --security-opt=seccomp=unconfined can be passed with no default.json required, but note that this will reduce the security of the host against malicious code in the container.

musl というライブラリがアップデートされたことにより32bit環境において時間に関する仕様変更があったようで、これを回避するためには --security-opt=seccomp=unconfined というオプション付きで docker run すれば良さそうです。

--security-opt=seccomp=unconfined はコンテナのセキュリティレベルが下がるようなので使用の際には注意が必要です。


apk updateが成功した

$ docker run -it --security-opt=seccomp=unconfined alpine:latest sh
/ # apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/armhf/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/armhf/APKINDEX.tar.gz
v3.13.2-48-gab9fbf8bd8 [https://dl-cdn.alpinelinux.org/alpine/v3.13/main]
v3.13.2-47-gc4030f9597 [https://dl-cdn.alpinelinux.org/alpine/v3.13/community]
OK: 12247 distinct packages available


/ # date
Mon Mar  1 03:00:00 UTC 2021

docker-compose.yml ではどうする?


    image: alpine:latest
    container_name: alpine
    command: sh
    tty: true
      - seccomp=unconfined


Raspberry PiのDocker環境でAlpine Linuxイメージを正常に扱えるようになりました。Raspberry Piだけでなく32bit環境では今回の対応を行わないと正常にコンテナが扱えなさそうでした。

Have a happy tech life!