LoginSignup
2
7

More than 3 years have passed since last update.

dockerコマンドをsudo無しで実行する簡単設定(Linux)

Last updated at Posted at 2020-09-15

Linux上でdockerコマンドをsudo無しで実行すると、以下の権限エラーが発生します。

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/json: dial unix /var/run/docker.sock: connect: permission denied

デフォルトではrootの実行権限が必要なのですが、以下の手順を使うことでsudo無しでdockerコマンドが叩けるようになります。

# dockerユーザーグループを作成
sudo groupadd docker
# 現在のユーザーをdockerグループに追加
sudo usermod -aG docker $USER
# 変更を即反映する
newgrp docker

注釈

  • ユーザーグループはインストール時に作成されているはずで本来不要なはずなのですが、公式ドキュメントに記載があったので、一応こちらにも記載しています。

参考

2
7
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
2
7