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

Rancher Desktop経由でインストールしたkubectlやdockerのPathがzshで通っていない時は

Posted at

Macでコンテナ環境構築するためにRancher Desktopを採用した。
Rancher DesktopはMacの場合、Homebrewからインストールが可能。

brew install --cask rancher

問題

kubectl, dockerコマンドが使用できることを確認するためバージョン表示を試みたが失敗。
(シェルにはzshを使用。)

 % kubectl verion
zsh: command not found: kubectl
% docker --version
zsh: command not found: docker

解決策

公式ドキュメントには、以下を実行するように回答があった。

echo "export PATH=\$PATH:/home/$(whoami)/.local/bin" >> ~/.bashrc

このコマンドでは.bashrcにパスを通している。Rancher Desktopのインストール時も使用しているシェルがbashの想定で行われており、zsh向けの設定がされていないのではないかと推測。
推測通り、~/.bashrcに下記のような内容が記載されていた。

### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
export PATH="/Users/username/.rd/bin:$PATH"
### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT)

.zshrcに上記内容を転記して、source ~/.zshrcを実行。
コマンドが実行できるようになっていることを確認。

% kubectl version  
Client Version: v1.32.3
Kustomize Version: v5.5.0
Server Version: v1.31.6+k3s1

% docker --version 
Docker version 27.5.1-rd, build 0c97515
0
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
0
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?