文書の過去の版を表示しています。


Docker - 仮想化コンテナ

Docker Logo
Docker (ドッカー) は、コンテナと呼ばれるOSレベルの仮想化(英語版)環境を提供するオープンソースソフトウェアである。VMware 製品などの完全仮想化を行うハイパーバイザ型製品と比べて、ディスク使用量は少なく、仮想環境(インスタンス) 作成や起動は速く、性能劣化がほとんどないという利点を持つ。
Docker - Wikiwand より

本家: Docker: Accelerated Container Application Development
ソースコード: GitHub - docker/docker-ce: Docker CE
ドキュメント: Docker ドキュメント日本語化プロジェクト — Docker-docs-ja 24.0 ドキュメント

Docker - 仮想化コンテナ (Windows)

公式: Install Docker Engine on Fedora | Docker Docs 翻訳

$ sudo dnf -y install dnf-plugins-core

メタデータの期限切れの最終確認: 1:53:37 時間前の 2023年09月06日 13時37分34秒 に実施しました。
パッケージ dnf-plugins-core-4.4.2-1.fc38.noarch は既にインストールされています。
依存関係が解決しました。
行うべきことはありません。
完了しました!

$ sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo

repo の追加: https://download.docker.com/linux/fedora/docker-ce.repo

$ sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Docker CE Stable - x86_64                                                            23 kB/s |  14 kB     00:00    
依存関係が解決しました。
====================================================================================================================
 パッケージ                          アーキテクチャー バージョン                   リポジトリー               サイズ
====================================================================================================================
インストール:
 containerd.io                       x86_64           1.6.22-3.1.fc38              docker-ce-stable            33 M
 docker-buildx-plugin                x86_64           0.11.2-1.fc38                docker-ce-stable            13 M
 docker-ce                           x86_64           3:24.0.6-1.fc38              docker-ce-stable            24 M
 docker-ce-cli                       x86_64           1:24.0.6-1.fc38              docker-ce-stable           7.1 M
 docker-compose-plugin               x86_64           2.21.0-1.fc38                docker-ce-stable            13 M
依存関係のインストール:
 docker-ce-rootless-extras           x86_64           24.0.6-1.fc38                docker-ce-stable           3.9 M
 libcgroup                           x86_64           3.0-2.fc38                   fedora                      75 k

トランザクションの概要
====================================================================================================================
インストール  7 パッケージ

ダウンロードサイズの合計: 93 M
インストール後のサイズ: 366 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/7): docker-buildx-plugin-0.11.2-1.fc38.x86_64.rpm                                1.5 MB/s |  13 MB     00:08    
(2/7): docker-ce-24.0.6-1.fc38.x86_64.rpm                                           1.5 MB/s |  24 MB     00:15    
(3/7): docker-ce-cli-24.0.6-1.fc38.x86_64.rpm                                       917 kB/s | 7.1 MB     00:07    
(4/7): docker-ce-rootless-extras-24.0.6-1.fc38.x86_64.rpm                           1.5 MB/s | 3.9 MB     00:02    
(5/7): libcgroup-3.0-2.fc38.x86_64.rpm                                               82 kB/s |  75 kB     00:00    
(6/7): containerd.io-1.6.22-3.1.fc38.x86_64.rpm                                     1.4 MB/s |  33 MB     00:23    
(7/7): docker-compose-plugin-2.21.0-1.fc38.x86_64.rpm                               1.8 MB/s |  13 MB     00:06    
--------------------------------------------------------------------------------------------------------------------
合計                                                                                3.6 MB/s |  93 MB     00:25     
Docker CE Stable - x86_64                                                           7.8 kB/s | 1.6 kB     00:00    
GPG 鍵 0x621E9F35 をインポート中:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://download.docker.com/linux/fedora/gpg
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                                                            1/1 
  インストール中   : docker-compose-plugin-2.21.0-1.fc38.x86_64                                                 1/7 
  scriptletの実行中: docker-compose-plugin-2.21.0-1.fc38.x86_64                                                 1/7 
  インストール中   : libcgroup-3.0-2.fc38.x86_64                                                                2/7 
  インストール中   : docker-buildx-plugin-0.11.2-1.fc38.x86_64                                                  3/7 
  scriptletの実行中: docker-buildx-plugin-0.11.2-1.fc38.x86_64                                                  3/7 
  インストール中   : docker-ce-cli-1:24.0.6-1.fc38.x86_64                                                       4/7 
  scriptletの実行中: docker-ce-cli-1:24.0.6-1.fc38.x86_64                                                       4/7 
  インストール中   : containerd.io-1.6.22-3.1.fc38.x86_64                                                       5/7 
  scriptletの実行中: containerd.io-1.6.22-3.1.fc38.x86_64                                                       5/7 
  インストール中   : docker-ce-rootless-extras-24.0.6-1.fc38.x86_64                                             6/7 
  scriptletの実行中: docker-ce-rootless-extras-24.0.6-1.fc38.x86_64                                             6/7 
  インストール中   : docker-ce-3:24.0.6-1.fc38.x86_64                                                           7/7 
  scriptletの実行中: docker-ce-3:24.0.6-1.fc38.x86_64                                                           7/7 
  検証             : containerd.io-1.6.22-3.1.fc38.x86_64                                                       1/7 
  検証             : docker-buildx-plugin-0.11.2-1.fc38.x86_64                                                  2/7 
  検証             : docker-ce-3:24.0.6-1.fc38.x86_64                                                           3/7 
  検証             : docker-ce-cli-1:24.0.6-1.fc38.x86_64                                                       4/7 
  検証             : docker-ce-rootless-extras-24.0.6-1.fc38.x86_64                                             5/7 
  検証             : docker-compose-plugin-2.21.0-1.fc38.x86_64                                                 6/7 
  検証             : libcgroup-3.0-2.fc38.x86_64                                                                7/7 

インストール済み:
  containerd.io-1.6.22-3.1.fc38.x86_64                       docker-buildx-plugin-0.11.2-1.fc38.x86_64             
  docker-ce-3:24.0.6-1.fc38.x86_64                           docker-ce-cli-1:24.0.6-1.fc38.x86_64                  
  docker-ce-rootless-extras-24.0.6-1.fc38.x86_64             docker-compose-plugin-2.21.0-1.fc38.x86_64            
  libcgroup-3.0-2.fc38.x86_64                               

完了しました!

$ sudo systemctl enable --now docker

Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

$ sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete 
Digest: sha256:dcba6daec718f547568c562956fa47e1b03673dd010fe6ee58ca806767031d1c
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Linux post-installation steps for Docker Engine | Docker Docs 翻訳
Docker デーモンは Unix ソケットにバインドするので、デフォルトでは、Unix ソケットを所有するのは root ユーザーであり、他のユーザーは sudo を使用してのみそれにアクセスできる。Docker デーモンは常に root ユーザーとして実行される。

$ docker run hello-world

docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

$ sudo ls -al /var/run/docker.sock

srw-rw---- 1 root docker 0  9月  6 15:43 /var/run/docker.sock

非 root ユーザーとして Docker を管理するには… (開発環境向け)

docker グループを作成する。(通常はインストール時に作成されている)

$ sudo groupadd docker

groupadd: グループ 'docker' は既に存在します

Docker を管理するユーザーを docker グループに追加する。

$ id tomoyan

uid=1000(tomoyan) gid=1000(tomoyan) groups=1000(tomoyan),10(wheel),135(mock)

$ sudo usermod -aG docker $USER

$ id tomoyan        

uid=1000(tomoyan) gid=1000(tomoyan) groups=1000(tomoyan),10(wheel),135(mock),974(docker)

再ログインするか、もしくは、以下のコマンドを実行してグループへの変更を有効化する。

$ newgrp docker


開発環境では docker グループに所属するユーザーは、sudo で管理者実行する必要がなくなるので作業効率がアップします😍💕💕💕

$ docker run hello-world


Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/



Docker からこんにちは!
このメッセージは、インストールが正しく動作していることを示しています。

このメッセージを生成するために、Docker は次の手順を実行しました。
 1. Docker クライアントが Docker デーモンに接続しました。
 2. Docker デーモンは、Docker Hub から「hello-world」イメージをプルしました。
    (amd64)
 3. Docker デーモンは、そのイメージから新しいコンテナを作成し、
    現在読んでいる出力を生成する実行可能ファイル。
 4. Docker デーモンはその出力を Docker クライアントにストリーミングし、Docker クライアントがそれを送信しました。
    端末に。

もっと野心的なことを試すには、次のコマンドを使用して Ubuntu コンテナを実行できます。
 $ docker run -it ubuntu bash

無料の Docker ID を使用して、イメージを共有したり、ワークフローを自動化したりできます。
 https://hub.docker.com/

その他の例やアイデアについては、以下を参照してください。
 https://docs.docker.com/get-started/

  • linux/docker.1706673829.txt.gz
  • 最終更新: 2024/01/31 13:03
  • by ともやん