docker - Development

  • 作成日:
  • 最終更新日:2025/06/25

必要なパッケージをインストール

sudo dnf -y install dnf-plugins-core

dnf-plugins-core は、dnf(Dandified YUM)コマンドに追加機能を提供するプラグイン集です。AlmaLinux や CentOS、RHEL 系ディストリビューションで使われます。

Docker の公式リポジトリを追加

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

config-manager は dnf-plugins-core に含まれるプラグインです。このパッケージがなければこのコマンドは動作しません。

Docker のインストール

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

インストールされたか以下のコマンドを実行し確認します。

docker version

Docker サービスの起動と自動起動設定

sudo systemctl start docker
sudo systemctl enable docker

動作確認用コマンド

以下のコマンドで hello-world コンテナが動けば成功です。

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 を使いたい場合(任意)

sudo usermod -aG docker $USER

※ 上記の変更を反映させるには、「 ログアウト→ログイン 」または 「 newgrp docker 」を実行します。