12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

docker pull時に dial unix /var/run/docker.sock: connect: permission denied が出る場合の対処法

Posted at

docker pull時に dial unix /var/run/docker.sock: connect: permission denied が出る場合の対処法

$ docker pull ubuntu:18.04
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/create?fromImage=ubuntu&tag=18.04: dial unix /var/run/docker.sock: connect: permission denied

/var/run/docker.sockはrootもしくはdockerグループのユーザしかアクセスできないようだ。

$ ls -l /var/run/docker.sock
srw-rw---- 1 root docker 0  7月  4 15:38 /var/run/docker.sock

なので、現在のユーザをdockerグループに追加する
以下はユーザID:ubuntuの例

$ sudo usermod -g docker ubuntu
$ sudo /bin/systemctl restart docker.service
$ id ubuntu
uid=1000(ubuntu) gid=999(docker) groups=999(docker),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare)

その後、ログアウト/ログインしてグループ追加設定を有効化する。
そして、再度、同手順を実行してpermission deniedが出ないことを確認する

$ docker pull ubuntu:18.04
(permission deniedが出ない)

参考

Ubuntu 18.04にDockerをインストールする
dockerコマンドをsudoの付与無しに実行できるようにする

12
4
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
12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?