17
11

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.

WSLでdockerをinstallするときにハマった話

Last updated at Posted at 2020-05-24

はじめに

基本的には、dockerの公式サイトを参考にinstallを進めます。ちなみにWSLでdockerをinstallします。

Install Docker Engine on Debian

環境

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
C:\Users\user>ver

Microsoft Windows [Version 10.0.18362.836]

(windows subsystem for linux)

➀GnuPG

$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
gpg: can't connect to the agent: IPC connect call failed

gpg、別名は「Gnu Privacy Guard」「GPG」「GnuPG」である。

これは、公開鍵でファイルの署名を検証したり、公開鍵と秘密鍵のペアでメールの暗号化・復号化を行ったり署名を添付したりするツールである。

解決方法Ⅰ

システム上でgpg-agentがすでに実行されている可能性があるので、gpg-agentを起動しなおす。

$ pkill -9 gpg-agent
$ source <(gpg-agent --daemon)

解決方法 Ⅱ

gpgをinstallし直す。自分はこれで解決した。

$ apt remove gpg
$ apt install gnupg1

➁apt-add-repository

~$ sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB]
Ign:3 https://download.docker.com/linux/debian focal InRelease
Err:4 https://download.docker.com/linux/debian focal Release
  404  Not Found [IP: 2600:9000:2157:4000:3:db06:4200:93a1 443]
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Reading package lists... Done
E: The repository 'https://download.docker.com/linux/debian focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

まだ公式にfocal versionがリリースされていないようである。(2020/05/18)

解決方法

$ sudo vi /etc/apt/sources.list

focal (ubuntu20.04) stableをコメントアウトして、eoan (ubuntu19.10) stableを追記する

# deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable
deb [arch=amd64] https://download.docker.com/linux/ubuntu eoan stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu focal stable

参考) Can’t install docker on Ubuntu 20.04

➂docker daemon

~$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

解決方法

(以下のコマンドはwslを「管理者として実行」から開く)

$ service docker start
 * Starting Docker: docker
$ service docker status
 * Docker is running

➃ユーザの所属グループ

$ docker run hello-world
docker: 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/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

解決方法

$ grep -i docker /etc/group
docker:x:999:
$ sudo gpasswd -a userhoge docker
[sudo] password for userhoge:
Adding user userhoge to group docker
$ grep -i docker /etc/group
docker:x:999:userhoge
17
11
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
17
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?