こんにちは。DAICHIです。
本記事では、Ubuntu Server 24.04へのDockerインストール手順を、初心者でも分かりやすくステップバイステップで解説します。公式ドキュメントに準拠した最新の方法を紹介しますので、最後までご参照ください。
コンテナ化技術の普及に伴い、Dockerは開発環境から本番運用まで、幅広いシーンで活用されています。特に、Ubuntu Serverはサーバー環境の標準的なOSとして多くのエンジニアに選ばれており、Ubuntu上でのDocker環境構築は必須スキルとなっています。
環境
Proxmoxに以下の構成でVMを作成して作業を行っています。
| OS | Ubuntu Server 24.04.3 |
| CPU | 4コア |
| RAM | 4GB |
| SSD | 40GB |
UbuntuにDockerをインストールする手順
Dockerのaptリポジトリを設定
パッケージリストを更新します。
sudo apt update必要なパッケージをインストールします。
sudo apt install -y ca-certificates curl公式GPGキーを保存するディレクトリを作成します。
sudo install -m 0755 -d /etc/apt/keyrings公式のGPGキーを取得します。
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.ascDockerリポジトリを追加します。
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOFパッケージリストを再度更新します。
このコマンドで、先ほど追加したDockerリポジトリの最新パッケージ情報が取得されます。
sudo apt updateDockerパッケージをインストール
最新バージョンのDockerをインストールします。
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginDockerの動作確認
Dockerが実行中であることを確認します。
※Dockerサービスはインストール後自動的に起動します。
sudo systemctl status docker公式テストイメージ「hello-world」を実行し、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/sudoなしでDockerコマンドを実行する設定
デフォルトではDocker操作にsudoが必要です。
頻繁にDockerコマンドを実行する場合は、ユーザーをdockerグループに追加することで効率化できます。
設定方法
dockerグループにユーザーを追加します。
sudo usermod -aG docker $USERグループ設定を反映する。
newgrp docker現在のユーザで再ログインする。
su - ${USER}sudo権限を使用せずに、公式テストイメージ「hello-world」を実行できるか確認する。
docker run hello-world最後
以上が、Ubuntu ServerにDockerをインストールする方法の解説となります。
本記事で紹介した手順に従うことで、安全で確実にDocker環境を構築できます。特にセキュリティを重視する本番環境では、公式リポジトリからのインストールが強く推奨されます。
ぜひこれをベースに、コンテナベースの開発・運用を始めてください。



















もし起動されていなければ、手動で起動します。