覚書き。
# ホームディレクトリに移動
cd
# インストール用スクリプトを取得
curl -fsSL https://get.docker.com -o get-docker.sh
# インストール
sudo sh get-docker.sh
# dockerグループにユーザを追加
sudo usermod -aG docker $USER
# コンテナイメージ一覧
docker image ls
(output)REPOSITORY TAG IMAGE ID CREATED SIZE
# インストール用スクリプト削除
rm get-docker.sh
できること
# コンテナ起動
docker container run hello-world
(output)Unable to find image 'hello-world:latest' locally
(output)latest: Pulling from library/hello-world
(output)c9c5fd25a1bd: Pull complete
(output)Digest: sha256:d715f14f9eca81473d9112dead457893aa4d099adeb4729f679006bf5ea12407
(output)Status: Downloaded newer image for hello-world:latest
(output)
(output)Hello from Docker!
(output)This message shows that your installation appears to be working correctly.
(output)(中略)
# コンテナイメージ一覧
docker image ls
(output)REPOSITORY TAG IMAGE ID CREATED SIZE
(output)hello-world latest f1f77a0f96b7 2 weeks ago 5.2kB
# ヘルプ
docker container --help
(output)(中略)
docker image --help
(output)(中略)
Pythonを実行してみる
# Python実行可能なコンテナイメージを取得
docker image pull python:3.12
(output)3.12: Pulling from library/python
(output)(中略)
(output)Digest: sha256:85ec4fe2a3f8ccac3315795f80c1cddeaddc496e892729548c716b120ea2c46a
(output)Status: Downloaded newer image for python:3.12
(output)docker.io/library/python:3.12
# Python実行
docker container run -v .:/workspace -it python:3.12 python --version
(output)Python 3.12.9
# コンテナ起動
docker container run -v .:/workspace -it python:3.12 bash
(output)
python --version
(output)Python 3.12.9
# 終了
exit