1
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?

Docker Desktop でインストールした docker-compose のパスが壊れたときの修復方法

Posted at

久々にプライベートのMacでDockerを触ろうとしたところ docker-compose のリンクが不正な向き先になっていてコマンドが実行できませんでした。

そもそもこのPCで docker-compose したことあるか自体記憶にないのですが(比較的最近買ったから)、リンクが正しくない以上composeでコンテナを動かせないので修復していきます。

環境

uname -a
Darwin macbook.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103 arm64
sw_vers --productVersion
15.0.1

修復方法

Docker Desktop に同梱されているインストーラを使ってシンボリックリンクを修復します。

まずはインストーラのヘルプを参照。
Available Commands: のうち、今回使うコマンドは config です。

/Applications/Docker.app/Contents/MacOS/install --help
[2024-10-13T09:37:54.424668000Z][install] executing:  /Applications/Docker.app/Contents/MacOS/install --help
Installs Docker Desktop.

Usage:
  install [flags]
  install [command]

Available Commands:
  add-kube-host                    add-kube-host adds kubernetes.docker.internal to /etc/hosts
  completion                       Generate the autocompletion script for the specified shell
  config                           installs symlinks into /usr/local/bin, creates a /var/run/docker.sock symlink, starts vmnetd
  help                             Help about any command
  remove-kube-host                 remove-kube-host removes kubernetes.docker.internal from /etc/hosts
  remove-socket-symlink-on-startup unregisters the startup task for the docker socket symlink
  remove-vmnetd                    Removes the vmned privileged process used for port binding
  socket-symlink-on-startup        Registers a startup task to symlink docker socket to /var/run/docker.sock
  vmnetd                           Launches the vmnetd for privileged port binding

Flags:
      --accept-license                  Accepts the Docker Subscription Service Agreement now, rather than requiring it to be accepted when the application is first run.
      --admin-settings string           Json string to use as admin settings for hardened desktop (needs to use --allowed-org and specify a business tier org).
      --allowed-org string              Requires the user to sign in and be part of the specified Docker Hub organization when running the application.
  -h, --help                            help for install
      --override-proxy-exclude string   Bypass proxy settings for these hosts & domains, comma-separated list.
      --override-proxy-http string      URL of the HTTP proxy that must be used for outgoing HTTP requests.
      --override-proxy-https string     URL of the HTTP proxy that must be used for outgoing HTTPS requests.
      --proxy-enable-kerberosntlm       Enable or disable Kerberos/NTLM proxy authentication support.
      --proxy-http-mode string          HTTP Proxy mode, system (default) or manual.
      --user string                     Setup symlinks for specified user, only one user is supported for now.

Use "install [command] --help" for more information about a command.

末尾に「Use "install [command] --help" for more information about a command.」とあるので参照します。

/Applications/Docker.app/Contents/MacOS/install config --help
[2024-10-13T09:38:52.474110000Z][install] executing:  /Applications/Docker.app/Contents/MacOS/install config --help
installs symlinks into /usr/local/bin, creates a /var/run/docker.sock symlink, starts vmnetd

Usage:
  install config [flags]

Flags:
  -h, --help          help for config
      --user string   Specifies the user to setup symlinks for

--user フラグでシンボリックリンクをセットアップするユーザを指定とのこと。
一応 /usr/local/bin 配下を確認して諸々のリンクは軒並みroot権限で作成されてたので、rootを指定して実行します。

sudo /Applications/Docker.app/Contents/MacOS/install config --user root

実行後に /usr/local/bin/ 配下を確認。
リンク修復前の記録を残すの忘れてしまったのですがちゃんと修復されています。

ls -l /usr/local/bin/docker*                                           
lrwxr-xr-x@ 1 root  wheel  54 10 13 18:34 /usr/local/bin/docker -> /Applications/Docker.app/Contents/Resources/bin/docker
lrwxr-xr-x@ 1 root  wheel  70 10 13 18:34 /usr/local/bin/docker-compose -> /Applications/Docker.app/Contents/Resources/cli-plugins/docker-compose
lrwxr-xr-x@ 1 root  wheel  73 10 13 18:34 /usr/local/bin/docker-credential-desktop -> /Applications/Docker.app/Contents/Resources/bin/docker-credential-desktop
lrwxr-xr-x@ 1 root  wheel  75 10 13 18:40 /usr/local/bin/docker-credential-ecr-login -> /Applications/Docker.app/Contents/Resources/bin/docker-credential-ecr-login
lrwxr-xr-x@ 1 root  wheel  77 10 13 18:34 /usr/local/bin/docker-credential-osxkeychain -> /Applications/Docker.app/Contents/Resources/bin/docker-credential-osxkeychain
lrwxr-xr-x@ 1 root  wheel  60 10 13 18:34 /usr/local/bin/docker-index -> /Applications/Docker.app/Contents/Resources/bin/docker-index

version 指定で実行してちゃんと結果が返ってきているので問題ありません。

which docker-compose
/usr/local/bin/docker-compose
docker-compose version
Docker Compose version v2.29.2-desktop.2
1
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
1
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?