0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UbuntuでDockerをアンインストールする方法

0
Posted at

UbuntuでDockerをアンインストールする方法

Ubuntu上でDockerを完全にアンインストールするには、以下の手順を実行してください。
これにより、Docker関連のパッケージ、コンテナ、イメージ、ボリュームなどが削除されます。


1. 実行中のコンテナを停止

まず、すべての実行中のコンテナを停止します。

docker stop $(docker ps -a -q)

2. コンテナとイメージを削除

停止したコンテナとイメージを削除します。

docker rm $(docker ps -a -q)   # すべてのコンテナを削除
docker rmi $(docker images -a -q)   # すべてのイメージを削除

3. ボリュームとネットワークを削除

未使用のボリュームやネットワークも削除します。

docker volume prune -f   # 未使用のボリュームを削除
docker network prune -f  # 未使用のネットワークを削除

4. Dockerサービスを停止

Dockerエンジンを停止します。

sudo systemctl stop docker

5. Docker関連パッケージをアンインストール

以下のコマンドでDocker関連パッケージを削除します。

sudo apt-get purge -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo apt-get autoremove -y   # 不要な依存関係も削除

6. データディレクトリを削除

Dockerデータや設定ファイルが保存されているディレクトリを削除します。

sudo rm -rf /var/lib/docker /var/lib/containerd /etc/docker

7. Dockerグループを削除

Dockerグループも不要であれば削除します。

sudo groupdel docker

8. 確認

最後に、以下のコマンドでDockerが完全にアンインストールされたことを確認します。

docker --version   # コマンドが見つからない場合、アンインストール成功

注意点

  • アンインストール後は システム再起動を推奨 します。
  • 必要なデータがある場合は 事前にバックアップ してください。

これでUbuntuからDockerが完全にアンインストールされます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?