Pythonアプリ内からコンテナの実行・管理などが行える「Docker」のインストール

スポンサーリンク

Pythonアプリ内からコンテナの実行・管理などが行える「Docker」のインストールについて解説しています。

「Docker(https://docker-py.readthedocs.io/en/stable/)」は、DockerEngineAPI用のPythonライブラリです。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■Dockerをインストールする

Dockerをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install docker

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install docker

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting docker
Downloading docker-5.0.3-py2.py3-none-any.whl (146 kB)
|████████████████████████████████| 146 kB 1.3 MB/s
Requirement already satisfied: requests!=2.18.0,>=2.14.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from docker) (2.27.1)
Requirement already satisfied: websocket-client>=0.32.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from docker) (1.1.0)
Collecting pywin32==227
Downloading pywin32-227-cp38-cp38-win_amd64.whl (9.1 MB)
|████████████████████████████████| 9.1 MB 6.8 MB/s
Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests!=2.18.0,>=2.14.2->docker) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests!=2.18.0,>=2.14.2->docker) (2021.5.30)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests!=2.18.0,>=2.14.2->docker) (2.0.12)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests!=2.18.0,>=2.14.2->docker) (1.26.9)
Installing collected packages: pywin32, docker
Attempting uninstall: pywin32
Found existing installation: pywin32 303
Uninstalling pywin32-303:
Successfully uninstalled pywin32-303
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
web3 5.24.0 requires jsonschema<4.0.0,>=3.2.0, but you have jsonschema 4.4.0 which is incompatible.
web3 5.24.0 requires websockets<10,>=9.1, but you have websockets 10.2 which is incompatible.
pybrowsers 0.3.0 requires pywin32<304,>=303; sys_platform == "win32", but you have pywin32 227 which is incompatible.
Successfully installed docker-5.0.3 pywin32-227

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、Dockerが正常にインストールされたことになります。しかし、今回は「ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.(ERROR: pip の依存性解決は現在インストールされているすべてのパッケージを考慮に入れていません。この挙動は以下のような依存関係の衝突の原因となっています。)」という依存関係の衝突が原因でエラーが出力されました。このようなエラーを解決するためには、仮想環境を構築し、その上でインストールされることを推奨する。

なお、今回はDockerのバージョン5.0.3をインストールしました。

コメント

タイトルとURLをコピーしました