最新のDockerインストール方法を、ラズパイ専用のサイトにまとめましたので、是非ご覧ください。
【2023年最新】Raspberry PiにDockerとDocker Composeをインストールする
以下は2021年当時の内容となります。
前回の記事ではRaspberry PiにDockerをインストールしました。
今回はDocker ComposeをRaspberry Piにインストールしてみます。
対象
項目 | 説明 |
Raspberry Pi | Raspberry Pi 4 model B 8GB |
OS | Raspberry Pi OS 64bit |
インストール済みパッケージ | Docker |
事前調査
前回のDockerインストールと同様に、まずは公式サイトをのぞいてみます。
https://docs.docker.com/compose/install/
Raspberry Piへのインストールに関してのそのものズバリの記載はありませんでしたので、Linuxへのインストール方法を確認してみます。
LinuxへDocker Composeをインストールする方法は現時点では以下の3つの方法がありそうです。
- GitHubからバイナリをダウンロード
- コンテナとしてインストール
- pipを利用してインストール
Raspberry Pi OS 64bitのアーキテクチャはaarch64なので、1番のバイナリは動かない気がしますが、全ての方法を試してみます。
方法1.GitHubからバイナリをダウンロード(失敗)
結論から言うとこの方法は使えませんでした。GitHubに置いてあるバイナリはx86_64用のものであり、Raspberry Piには適用できません。次の方法を試します。
方法2.コンテナとしてインストール(失敗)
Docker Composeをコンテナとしてインストールする方法です。こちらの方法が使えると環境を汚染せずにDocker Composeを利用できるため期待していたのですが、こちらもだめでした。
以下、実際にコンテナとしてインストールしてみた際のログです。試しにdocker-compose psコマンドで起動確認をしたところ、アーキテクチャが一致せず起動できないことを確認できました。
$ sudo curl -L --fail https://github.com/docker/compose/releases/download/1.29.1/run.sh -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 612 100 612 0 0 1096 0 --:--:-- --:--:-- --:--:-- 1098
100 2585 100 2585 0 0 3207 0 --:--:-- --:--:-- --:--:-- 73857
$ sudo chmod +x /usr/local/bin/docker-compose
$ docker-compose ps
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
standard_init_linux.go:219: exec user process caused: exec format error
方法3.pipを利用してインストール(成功、でもちょっとした落とし穴あり)
pip(Pythonのパッケージマネージャ)を利用してインストールしてみます。
pip3 install docker-composeコマンドでエラー発生
PyPiのプロジェクト検索にてDocker Composeを調べてみたところ、pip経由でDocker Composeをインストールする場合、Pythonのバージョンは3.6以上でないといけないことが分かりました。Raspberry Pi OS 64bitにてpipコマンドを使う場合、デフォルトではPython 2.7が利用されてしまうため、明示的にpip3としてPython 3を利用するようにします。(落とし穴1つめ)
$ pip3 install docker-compose
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting docker-compose
Downloading https://files.pythonhosted.org/packages/68/5f/341e60edaff653942ae78d3036eb7fa0994b53582ed87beb8317d182d70f/docker_compose-1.29.1-py2.py3-none-any.whl (114kB)
100% |████████████████████████████████| 122kB 2.3MB/s
Collecting websocket-client<1,>=0.32.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/08/33/80e0d4f60e84a1ddd9a03f340be1065a2a363c47ce65c4bd3bae65ce9631/websocket_client-0.58.0-py2.py3-none-any.whl (61kB)
100% |████████████████████████████████| 61kB 2.4MB/s
Collecting PyYAML<6,>=3.10 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz (175kB)
100% |████████████████████████████████| 184kB 2.0MB/s
Installing build dependencies ... done
Requirement already satisfied: requests<3,>=2.20.0 in /usr/lib/python3/dist-packages (from docker-compose) (2.21.0)
Collecting jsonschema<4,>=2.5.1 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/c5/8f/51e89ce52a085483359217bc72cdbf6e75ee595d5b1d4b5ade40c7e018b8/jsonschema-3.2.0-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 2.8MB/s
Collecting docopt<1,>=0.6.1 (from docker-compose)
Downloading https://www.piwheels.org/simple/docopt/docopt-0.6.2-py2.py3-none-any.whl
Collecting dockerpty<1,>=0.4.1 (from docker-compose)
Downloading https://www.piwheels.org/simple/dockerpty/dockerpty-0.4.1-py3-none-any.whl
Collecting cached-property<2,>=1.2.0; python_version < "3.8" (from docker-compose)
Downloading https://files.pythonhosted.org/packages/48/19/f2090f7dad41e225c7f2326e4cfe6fff49e57dedb5b53636c9551f86b069/cached_property-1.5.2-py2.py3-none-any.whl
Collecting texttable<2,>=0.9.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/06/f5/46201c428aebe0eecfa83df66bf3e6caa29659dbac5a56ddfd83cae0d4a4/texttable-1.6.3-py2.py3-none-any.whl
Collecting distro<2,>=1.5.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/25/b7/b3c4270a11414cb22c6352ebc7a83aaa3712043be29daa05018fd5a5c956/distro-1.5.0-py2.py3-none-any.whl
Collecting docker[ssh]>=5 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/b2/5a/f988909dfed18c1ac42ad8d9e611e6c5657e270aa6eb68559985dbb69c13/docker-5.0.0-py2.py3-none-any.whl (146kB)
100% |████████████████████████████████| 153kB 2.2MB/s
Collecting python-dotenv<1,>=0.13.0 (from docker-compose)
Downloading https://files.pythonhosted.org/packages/86/62/aacbd1489fc6026c9278e9fd5cfdd49c5b1b5375d3c97a624e8f8f999eb2/python_dotenv-0.17.0-py2.py3-none-any.whl
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from websocket-client<1,>=0.32.0->docker-compose) (1.12.0)
Collecting importlib-metadata; python_version < "3.8" (from jsonschema<4,>=2.5.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/41/fb/3433b27dbf9bcfe48286dbc29b918e312cbbcc23de6686cc40b81b0180de/importlib_metadata-4.0.0-py3-none-any.whl
Collecting attrs>=17.4.0 (from jsonschema<4,>=2.5.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/c3/aa/cb45262569fcc047bf070b5de61813724d6726db83259222cd7b4c79821a/attrs-20.3.0-py2.py3-none-any.whl (49kB)
100% |████████████████████████████████| 51kB 2.8MB/s
Collecting pyrsistent>=0.14.0 (from jsonschema<4,>=2.5.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/4d/70/fd441df751ba8b620e03fd2d2d9ca902103119616f0f6cc42e6405035062/pyrsistent-0.17.3.tar.gz (106kB)
100% |████████████████████████████████| 112kB 3.0MB/s
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from jsonschema<4,>=2.5.1->docker-compose) (40.8.0)
Collecting paramiko>=2.4.2; extra == "ssh" (from docker[ssh]>=5->docker-compose)
Downloading https://files.pythonhosted.org/packages/95/19/124e9287b43e6ff3ebb9cdea3e5e8e88475a873c05ccdf8b7e20d2c4201e/paramiko-2.7.2-py2.py3-none-any.whl (206kB)
100% |████████████████████████████████| 215kB 2.0MB/s
Collecting zipp>=0.5 (from importlib-metadata; python_version < "3.8"->jsonschema<4,>=2.5.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/0f/8c/715c54e9e34c0c4820f616a913a7de3337d0cd79074dd1bed4dd840f16ae/zipp-3.4.1-py3-none-any.whl
Collecting typing-extensions>=3.6.4; python_version < "3.8" (from importlib-metadata; python_version < "3.8"->jsonschema<4,>=2.5.1->docker-compose)
Downloading https://files.pythonhosted.org/packages/60/7a/e881b5abb54db0e6e671ab088d079c57ce54e8a01a3ca443f561ccadb37e/typing_extensions-3.7.4.3-py3-none-any.whl
Collecting pynacl>=1.0.1 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]>=5->docker-compose)
Downloading https://files.pythonhosted.org/packages/cf/5a/25aeb636baeceab15c8e57e66b8aa930c011ec1c035f284170cacb05025e/PyNaCl-1.4.0.tar.gz (3.4MB)
100% |████████████████████████████████| 3.4MB 159kB/s
Installing build dependencies ... error
Complete output from command /usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-im22819t --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools>=40.8.0 wheel "cffi>=1.4.1; python_implementation != 'PyPy'":
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple, https://www.piwheels.org/simple
Collecting setuptools>=40.8.0
Using cached https://files.pythonhosted.org/packages/ae/42/2876a3a136f8bfa9bd703518441c8db78ff1eeaddf174baa85c083c1fd15/setuptools-56.0.0-py3-none-any.whl
Collecting wheel
Using cached https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl
Collecting cffi>=1.4.1
Downloading https://files.pythonhosted.org/packages/a8/20/025f59f929bbcaa579704f443a438135918484fffaacfaddba776b374563/cffi-1.14.5.tar.gz (475kB)
Collecting pycparser (from cffi>=1.4.1)
Downloading https://files.pythonhosted.org/packages/ae/e7/d9c3a176ca4b02024debf82342dab36efadfc5776f9c8db077e8f6e71821/pycparser-2.20-py2.py3-none-any.whl (112kB)
Building wheels for collected packages: cffi
Running setup.py bdist_wheel for cffi: started
Running setup.py bdist_wheel for cffi: finished with status 'error'
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-__ssr652/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-kvtr5joq --python-tag cp37:
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-aarch64-3.7
creating build/lib.linux-aarch64-3.7/cffi
copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/commontypes.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/api.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/lock.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/cparser.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/verifier.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/error.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/vengine_gen.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/__init__.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/recompiler.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/pkgconfig.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/ffiplatform.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/model.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/_cffi_include.h -> build/lib.linux-aarch64-3.7/cffi
copying cffi/parse_c_type.h -> build/lib.linux-aarch64-3.7/cffi
copying cffi/_embedding.h -> build/lib.linux-aarch64-3.7/cffi
copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-3.7/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.linux-aarch64-3.7
creating build/temp.linux-aarch64-3.7/c
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.7m -c c/_cffi_backend.c -o build/temp.linux-aarch64-3.7/c/_cffi_backend.o
c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^~~~~~~
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for cffi
Running setup.py clean for cffi
Failed to build cffi
Installing collected packages: setuptools, wheel, pycparser, cffi
Running setup.py install for cffi: started
Running setup.py install for cffi: finished with status 'error'
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-__ssr652/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-jw6c9_ww/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-im22819t --compile:
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
running install
running build
running build_py
creating build
creating build/lib.linux-aarch64-3.7
creating build/lib.linux-aarch64-3.7/cffi
copying cffi/setuptools_ext.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/commontypes.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/api.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/lock.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/cparser.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/vengine_cpy.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/verifier.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/error.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/vengine_gen.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/__init__.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/recompiler.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/pkgconfig.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/ffiplatform.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/cffi_opcode.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/backend_ctypes.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/model.py -> build/lib.linux-aarch64-3.7/cffi
copying cffi/_cffi_include.h -> build/lib.linux-aarch64-3.7/cffi
copying cffi/parse_c_type.h -> build/lib.linux-aarch64-3.7/cffi
copying cffi/_embedding.h -> build/lib.linux-aarch64-3.7/cffi
copying cffi/_cffi_errors.h -> build/lib.linux-aarch64-3.7/cffi
running build_ext
building '_cffi_backend' extension
creating build/temp.linux-aarch64-3.7
creating build/temp.linux-aarch64-3.7/c
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.7m -c c/_cffi_backend.c -o build/temp.linux-aarch64-3.7/c/_cffi_backend.o
c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^~~~~~~
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-__ssr652/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-jw6c9_ww/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-im22819t --compile" failed with error code 1 in /tmp/pip-install-__ssr652/cffi/
----------------------------------------
Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-im22819t --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools>=40.8.0 wheel "cffi>=1.4.1; python_implementation != 'PyPy'"" failed with error code 1 in None
・・・
c/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^~~~~~~
compilation terminated.
error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-__ssr652/cffi/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-jw6c9_ww/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-im22819t --compile" failed with error code 1 in /tmp/pip-install-__ssr652/cffi/
----------------------------------------
Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-im22819t --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple -- setuptools>=40.8.0 wheel "cffi>=1.4.1; python_implementation != 'PyPy'"" failed with error code 1 in None
どうやらffi.hというヘッダファイルがなくてコンパイルに失敗したようです。(落とし穴2つ目)
libffi-devをインストールし、再度pip3 install docker-composeを実行
Debianパッケージ検索にてffi.hを検索してみたところ、libffi-devパッケージをインストールすればいけそうな感じでしたので、libffi-devパッケージをインストールして再チャレンジします。
$ sudo apt install libffi-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libffi-dev
0 upgraded, 1 newly installed, 0 to remove and 74 not upgraded.
Need to get 155 kB of archives.
After this operation, 349 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main arm64 libffi-dev arm64 3.2.1-9 [155 kB]
Fetched 155 kB in 0s (916 kB/s)
Selecting previously unselected package libffi-dev:arm64.
(Reading database ... 89524 files and directories currently installed.)
Preparing to unpack .../libffi-dev_3.2.1-9_arm64.deb ...
Unpacking libffi-dev:arm64 (3.2.1-9) ...
Setting up libffi-dev:arm64 (3.2.1-9) ...
Processing triggers for man-db (2.8.5-2) ...
$ pip3 install docker-compose
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting docker-compose
Using cached https://files.pythonhosted.org/packages/68/5f/341e60edaff653942ae78d3036eb7fa0994b53582ed87beb8317d182d70f/docker_compose-1.29.1-py2.py3-none-any.whl
Collecting websocket-client<1,>=0.32.0 (from docker-compose)
Using cached https://files.pythonhosted.org/packages/08/33/80e0d4f60e84a1ddd9a03f340be1065a2a363c47ce65c4bd3bae65ce9631/websocket_client-0.58.0-py2.py3-none-any.whl
Collecting jsonschema<4,>=2.5.1 (from docker-compose)
Using cached https://files.pythonhosted.org/packages/c5/8f/51e89ce52a085483359217bc72cdbf6e75ee595d5b1d4b5ade40c7e018b8/jsonschema-3.2.0-py2.py3-none-any.whl
Collecting dockerpty<1,>=0.4.1 (from docker-compose)
Using cached https://www.piwheels.org/simple/dockerpty/dockerpty-0.4.1-py3-none-any.whl
Requirement already satisfied: requests<3,>=2.20.0 in /usr/lib/python3/dist-packages (from docker-compose) (2.21.0)
Collecting distro<2,>=1.5.0 (from docker-compose)
Using cached https://files.pythonhosted.org/packages/25/b7/b3c4270a11414cb22c6352ebc7a83aaa3712043be29daa05018fd5a5c956/distro-1.5.0-py2.py3-none-any.whl
Collecting python-dotenv<1,>=0.13.0 (from docker-compose)
Using cached https://files.pythonhosted.org/packages/86/62/aacbd1489fc6026c9278e9fd5cfdd49c5b1b5375d3c97a624e8f8f999eb2/python_dotenv-0.17.0-py2.py3-none-any.whl
Collecting docopt<1,>=0.6.1 (from docker-compose)
Using cached https://www.piwheels.org/simple/docopt/docopt-0.6.2-py2.py3-none-any.whl
Collecting cached-property<2,>=1.2.0; python_version < "3.8" (from docker-compose)
Using cached https://files.pythonhosted.org/packages/48/19/f2090f7dad41e225c7f2326e4cfe6fff49e57dedb5b53636c9551f86b069/cached_property-1.5.2-py2.py3-none-any.whl
Collecting texttable<2,>=0.9.0 (from docker-compose)
Using cached https://files.pythonhosted.org/packages/06/f5/46201c428aebe0eecfa83df66bf3e6caa29659dbac5a56ddfd83cae0d4a4/texttable-1.6.3-py2.py3-none-any.whl
Collecting PyYAML<6,>=3.10 (from docker-compose)
Using cached https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz
Installing build dependencies ... done
Collecting docker[ssh]>=5 (from docker-compose)
Using cached https://files.pythonhosted.org/packages/b2/5a/f988909dfed18c1ac42ad8d9e611e6c5657e270aa6eb68559985dbb69c13/docker-5.0.0-py2.py3-none-any.whl
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from websocket-client<1,>=0.32.0->docker-compose) (1.12.0)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from jsonschema<4,>=2.5.1->docker-compose) (40.8.0)
Collecting pyrsistent>=0.14.0 (from jsonschema<4,>=2.5.1->docker-compose)
Using cached https://files.pythonhosted.org/packages/4d/70/fd441df751ba8b620e03fd2d2d9ca902103119616f0f6cc42e6405035062/pyrsistent-0.17.3.tar.gz
Collecting attrs>=17.4.0 (from jsonschema<4,>=2.5.1->docker-compose)
Using cached https://files.pythonhosted.org/packages/c3/aa/cb45262569fcc047bf070b5de61813724d6726db83259222cd7b4c79821a/attrs-20.3.0-py2.py3-none-any.whl
Collecting importlib-metadata; python_version < "3.8" (from jsonschema<4,>=2.5.1->docker-compose)
Using cached https://files.pythonhosted.org/packages/41/fb/3433b27dbf9bcfe48286dbc29b918e312cbbcc23de6686cc40b81b0180de/importlib_metadata-4.0.0-py3-none-any.whl
Collecting paramiko>=2.4.2; extra == "ssh" (from docker[ssh]>=5->docker-compose)
Using cached https://files.pythonhosted.org/packages/95/19/124e9287b43e6ff3ebb9cdea3e5e8e88475a873c05ccdf8b7e20d2c4201e/paramiko-2.7.2-py2.py3-none-any.whl
Collecting typing-extensions>=3.6.4; python_version < "3.8" (from importlib-metadata; python_version < "3.8"->jsonschema<4,>=2.5.1->docker-compose)
Using cached https://files.pythonhosted.org/packages/60/7a/e881b5abb54db0e6e671ab088d079c57ce54e8a01a3ca443f561ccadb37e/typing_extensions-3.7.4.3-py3-none-any.whl
Collecting zipp>=0.5 (from importlib-metadata; python_version < "3.8"->jsonschema<4,>=2.5.1->docker-compose)
Using cached https://files.pythonhosted.org/packages/0f/8c/715c54e9e34c0c4820f616a913a7de3337d0cd79074dd1bed4dd840f16ae/zipp-3.4.1-py3-none-any.whl
Collecting pynacl>=1.0.1 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]>=5->docker-compose)
Using cached https://files.pythonhosted.org/packages/cf/5a/25aeb636baeceab15c8e57e66b8aa930c011ec1c035f284170cacb05025e/PyNaCl-1.4.0.tar.gz
Installing build dependencies ... done
Collecting bcrypt>=3.1.3 (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]>=5->docker-compose)
Downloading https://files.pythonhosted.org/packages/d8/ba/21c475ead997ee21502d30f76fd93ad8d5858d19a3fad7cd153de698c4dd/bcrypt-3.2.0.tar.gz (42kB)
100% |████████████████████████████████| 51kB 2.2MB/s
Installing build dependencies ... done
Requirement already satisfied: cryptography>=2.5 in /usr/lib/python3/dist-packages (from paramiko>=2.4.2; extra == "ssh"->docker[ssh]>=5->docker-compose) (2.6.1)
Collecting cffi>=1.4.1 (from pynacl>=1.0.1->paramiko>=2.4.2; extra == "ssh"->docker[ssh]>=5->docker-compose)
Collecting pycparser (from cffi>=1.4.1->pynacl>=1.0.1->paramiko>=2.4.2; extra == "ssh"->docker[ssh]>=5->docker-compose)
Using cached https://files.pythonhosted.org/packages/ae/e7/d9c3a176ca4b02024debf82342dab36efadfc5776f9c8db077e8f6e71821/pycparser-2.20-py2.py3-none-any.whl
Building wheels for collected packages: PyYAML, pyrsistent, pynacl, bcrypt
Running setup.py bdist_wheel for PyYAML ... done
Stored in directory: /home/pi/.cache/pip/wheels/2a/d4/92/cf299bdf4162957ca8126b46e913e29f76a4f17ca762c45028
Running setup.py bdist_wheel for pyrsistent ... done
Stored in directory: /home/pi/.cache/pip/wheels/f0/b8/de/b593ad311be4eb458499d100db081e453576032272398b7ddc
Running setup.py bdist_wheel for pynacl ... done
Stored in directory: /home/pi/.cache/pip/wheels/c2/d9/ca/81e002fb0cee770c198715dace9edab919daba3ae49bd287a0
Running setup.py bdist_wheel for bcrypt ... done
Stored in directory: /home/pi/.cache/pip/wheels/df/ff/0f/e588ec95ea51f480627d66264f5587f4105694ab7ddd61e711
Successfully built PyYAML pyrsistent pynacl bcrypt
...
Installing collected packages: websocket-client, pyrsistent, attrs, typing-extensions, zipp, importlib-metadata, jsonschema, dockerpty, distro, python-dotenv, docopt, cached-property, texttable, PyYAML, pycparser, cffi, pynacl, bcrypt, paramiko, docker, docker-compose
The script jsonschema is installed in '/home/pi/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
The script distro is installed in '/home/pi/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
The script dotenv is installed in '/home/pi/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
The script docker-compose is installed in '/home/pi/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed PyYAML-5.4.1 attrs-20.3.0 bcrypt-3.2.0 cached-property-1.5.2 cffi-1.14.5 distro-1.5.0 docker-5.0.0 docker-compose-1.29.1 dockerpty-0.4.1 docopt-0.6.2 importlib-metadata-4.0.0 jsonschema-3.2.0 paramiko-2.7.2 pycparser-2.20 pynacl-1.4.0 pyrsistent-0.17.3 python-dotenv-0.17.0 texttable-1.6.3 typing-extensions-3.7.4.3 websocket-client-0.58.0 zipp-3.4.1
無事にDocker Composeのインストールが終わったようです。コンソールにもあるように、docker-composeのインストール先は/home/pi/.local/binとなっていて、PATHが通っていないため、PATHを通します。
$ echo 'export PATH=$PATH:~/.local/bin' >> ~/.bash_profile
一度ログアウトするまたはsource ~/.bash_profileコマンドを打つなどしてPATHの設定を反映させます。
その後、docker-composeコマンドを打ってみたらUsageが表示されましたので正しくインストールされていそうです。
動作確認
正しくインストールされているか、簡単なyamlファイルで確認してみます。
piユーザのホームディレクトリにhello-docker-composeディレクトリを追加して、その中に以下のdocker-compose.ymlを作成します。
version: "3" services: hello-world: image: hello-world:latest
docker-compose.ymlファイルを作成したら、以下のコマンドで起動を確認してみます。
$ cd ~/hello-docker-compose
$ docker-compose up
Creating network "hello-docker-compose_default" with the default driver
Creating hello-docker-compose_hello-world_1 ... done
Attaching to hello-docker-compose_hello-world_1
hello-world_1 |
hello-world_1 | Hello from Docker!
hello-world_1 | This message shows that your installation appears to be working correctly.
hello-world_1 |
hello-world_1 | To generate this message, Docker took the following steps:
hello-world_1 | 1. The Docker client contacted the Docker daemon.
hello-world_1 | 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
hello-world_1 | (arm64v8)
hello-world_1 | 3. The Docker daemon created a new container from that image which runs the
hello-world_1 | executable that produces the output you are currently reading.
hello-world_1 | 4. The Docker daemon streamed that output to the Docker client, which sent it
hello-world_1 | to your terminal.
hello-world_1 |
hello-world_1 | To try something more ambitious, you can run an Ubuntu container with:
hello-world_1 | $ docker run -it ubuntu bash
hello-world_1 |
hello-world_1 | Share images, automate workflows, and more with a free Docker ID:
hello-world_1 | https://hub.docker.com/
hello-world_1 |
hello-world_1 | For more examples and ideas, visit:
hello-world_1 | https://docs.docker.com/get-started/
hello-world_1 |
hello-docker-compose_hello-world_1 exited with code 0
hello-worldコンテナが起動したことを確認できました。
まとめ
Raspberry PiにDocker Composeをインストールするには、実質pipを利用する方法が使えることが分かりました。また、pipを使ってインストールする場合は事前にlibffi-devをインストールしておく必要がありました。これで快適なDocker生活(?)を送れそうです。
それではまた。