树莓派4B已装好64位Linux,并且装好了19.03.1版本的Docker,具体的安装步骤请参考《树莓派4B安装64位Linux(不用显示器键盘鼠标)》
apt-get update
apt-get install -y python python-pip
apt-get install libffi-dev
如果不安装libffi-dev的话,接下来在安装docker-compose的时候会报错,提示找不到ffi.h文件,错误信息如下:
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-md9kAN/python2.7-2.7.16=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-aarch64-2.7/c/_cffi_backend.o
c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
#include
^~~~~~~
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
pip install docker-compose
cd /usr/local/lib/python2.7/dist-packages && \
cp -r backports /usr/local/lib/python2.7/dist-packages/docker/transport/
如果不执行此操作,接下来在执行docker-compose命令的时候会报错,提示找不到名为ssl_match_hostname的module,错误信息如下:
File "/usr/local/lib/python2.7/dist-packages/docker/tls.py", line 5, in <module>
from .transport import SSLHTTPAdapter
File "/usr/local/lib/python2.7/dist-packages/docker/transport/__init__.py", line 3, in <module>
from .ssladapter import SSLHTTPAdapter
File "/usr/local/lib/python2.7/dist-packages/docker/transport/ssladapter.py", line 23, in <module>
from backports.ssl_match_hostname import match_hostname
ImportError: No module named ssl_match_hostname
root@raspbian:~# docker-compose version
docker-compose version 1.24.1, build 4667896
docker-py version: 3.7.3
CPython version: 2.7.16
OpenSSL version: OpenSSL 1.1.1c 28 May 2019
至此,在64位操作系统上安装docker-compose已经成功,希望您在安装的时候,本文能给您一些参考;
无论何时,官方的安装方法都是首选,那么本文为何要自己折腾这么多步骤呢?
sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
root@raspbian:~/harbor# echo https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)
https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-aarch64
从上述控制台信息可见,docker-compose的下载地址是https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-aarch64,这样的地址能否下载到对应的文件,您将其粘贴在浏览器访问一下便知道,这个地址会返回404错误;
3. 在一台x86架构的Linux服务器上试试,上述下载命令对应的地址是https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-x86_64,此地址是有效的,因此可以得出一个结论:docker官方并没有发布64位ARM架构的docker-compose安装文件
4. 如下图,在官方文档上可以看到1.24.1版的docker-compose共发布三个,没有ARM架构:
综上所述,在Docker官方不支持的背景下,只能采用变通策略,用pip来安装了。