macOSでDockerを再起動する

やり方

ターミナルでDockerを落として、Docker.appでもう一度起動する。

killall Docker && open /Applications/Docker.app

経緯

Dockerでmakeが入ってなかったのでインストールしようとしたらなぜかNetwork is Unreachableになって動かなかった。

root@215416af86a5:~/workspace/des# apt install make
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  make-doc
The following NEW packages will be installed:
  make
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 162 kB of archives.
After this operation, 393 kB of additional disk space will be used.
Err:1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal/main amd64 make amd64 4.2.1-1.2
  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
E: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/pool/main/m/make-dfsg/make_4.2.1-1.2_amd64.deb  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?


root@215416af86a5:~/workspace/des# apt install make
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  make-doc
The following NEW packages will be installed:
  make
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 162 kB of archives.
After this operation, 393 kB of additional disk space will be used.
Err:1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal/main amd64 make amd64 4.2.1-1.2
  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
E: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/pool/main/m/make-dfsg/make_4.2.1-1.2_amd64.deb  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
root@215416af86a5:~/workspace/des# apt update
Err:1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal InRelease
  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
Err:2 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-updates InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Err:3 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-backports InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Err:4 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-security InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Err:5 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease
  Could not connect to ppa.launchpad.net:80 (185.125.190.52). - connect (101: Network is unreachable)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal/InRelease  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-updates/InRelease  Unable to connect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-backports/InRelease  Unable to connect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-security/InRelease  Unable to connect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ppa.launchpad.net/ansible/ansible/ubuntu/dists/focal/InRelease  Could not connect to ppa.launchpad.net:80 (185.125.190.52). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.


root@215416af86a5:~/workspace/des# apt update
Err:1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal InRelease
  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
Err:2 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-updates InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Err:3 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-backports InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Err:4 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-security InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Err:5 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease
  Could not connect to ppa.launchpad.net:80 (185.125.190.52). - connect (101: Network is unreachable)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal/InRelease  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-updates/InRelease  Unable to c
onnect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-backports/InRelease  Unable to connect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-security/InRelease  Unable to connect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ppa.launchpad.net/ansible/ansible/ubuntu/dists/focal/InRelease  Could not c
onnect to ppa.launchpad.net:80 (185.125.190.52). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@215416af86a5:~/workspace/des# apt update
Err:1 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease
  Could not connect to ppa.launchpad.net:80 (185.125.190.52). - connect (101: Network is unreachable)
Err:2 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal InRelease
  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
Err:3 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-updates InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Err:4 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-backports InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Err:5 http://ftp.jaist.ac.jp/pub/Linux/ubuntu focal-security InRelease
  Unable to connect to ftp.jaist.ac.jp:http:
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal/InRelease  Could not connect to ftp.jaist.ac.jp:80 (150.65.7.130). - connect (101: Network is unreachable)
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-updates/InRelease  Unable to connect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-backports/InRelease  Unable to connect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-security/InRelease  Unable to connect to ftp.jaist.ac.jp:http:
W: Failed to fetch http://ppa.launchpad.net/ansible/ansible/ubuntu/dists/focal/InRelease  Could not connect to ppa.launchpad.net:80 (185.125.190.52). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.

ミラーサイトのjastのページに行っても普通に見れたのでそこが原因ではないっぽい。

http://ftp.jaist.ac.jp/pub/Linux/ubuntu/dists/focal-updates/InRelease

しかし原因が他に思い当たらないので、とりあえずsource.listを変えてみようとした。/etc/apt配下をみるとバックアップがあって、jaistのサイトではなかったので入れ替えてみた。やっては見たがまだNetwork is Unreachable

root@215416af86a5:/etc/apt# ll
total 44
drwxr-xr-x 1 root root 4096 Sep 19 15:27 ./
drwxr-xr-x 1 root root 4096 Sep 19 15:04 ../
drwxr-xr-x 1 root root 4096 Sep  9 21:35 apt.conf.d/
drwxr-xr-x 2 root root 4096 Apr  9  2020 auth.conf.d/
drwxr-xr-x 2 root root 4096 Apr  9  2020 preferences.d/
-rw-r--r-- 1 root root 2882 Sep  9 21:35 sources.list
-rw-r--r-- 1 root root 2743 Aug 27 01:50 sources.list.bak
drwxr-xr-x 1 root root 4096 Sep  9 21:35 sources.list.d/
-rw-r--r-- 1 root root 2882 Sep  9 21:35 sources.list.save
drwxr-xr-x 1 root root 4096 Sep  9 21:35 trusted.gpg.d/

root@215416af86a5:/etc/apt# cp -p sources.list sources.list.bak2

root@215416af86a5:/etc/apt# cp -p sources.list.bak sources.list

root@215416af86a5:/etc/apt# apt update
Err:1 http://ppa.launchpad.net/ansible/ansible/ubuntu focal InRelease
  Could not connect to ppa.launchpad.net:80 (185.125.190.52). - connect (101: Network is unreachable)
Err:2 http://archive.ubuntu.com/ubuntu focal InRelease
  Could not connect to archive.ubuntu.com:80 (185.125.190.36). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.91.38). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.91.39). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (185.125.190.39), connection timed out
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Unable to connect to archive.ubuntu.com:http:
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Unable to connect to archive.ubuntu.com:http:
Err:5 http://security.ubuntu.com/ubuntu focal-security InRelease
  Could not connect to security.ubuntu.com:80 (185.125.190.39). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.36), connection timed out
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Could not connect to archive.ubuntu.com:80 (185.125.190.36). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.91.38). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (91.189.91.39). - connect (101: Network is unreachable) Could not connect to archive.ubuntu.com:80 (185.125.190.39), connection timed out
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Unable to connect to archive.ubuntu.com:http:
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Unable to connect to archive.ubuntu.com:http:
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Could not connect to security.ubuntu.com:80 (185.125.190.39). - connect (101: Network is unreachable) Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (185.125.190.36), connection timed out
W: Failed to fetch http://ppa.launchpad.net/ansible/ansible/ubuntu/dists/focal/InRelease  Could not connect to ppa.launchpad.net:80 (185.125.190.52). - connect (101: Network is unreachable)
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@215416af86a5:/etc/apt# Error response from daemon: dial unix docker.raw.sock: connect: connection refused

macOSのタスクトレイを見てみるとアプリケーションが応答してない状態だったので、なんとかしてDockerを再起動してみる。

いろいろ検索してみて、macOS docker restart検索するとちょうどいいサイトが出てきた。

Restart Docker from command line - #6 by jforssell - Docker Desktop for Mac - Docker Community Forums

Aracrittyでkillall com.docker.osx.hyperkit.linuxだと反応が返ってこなかったので、killall Dockerをやるときちんと落とすことができた。そのあとはAlfredからDocker.appを起動して再起動できた。open /Applications/Docker.appは実行してないけど多分同じかなと。