0
0

More than 1 year has passed since last update.

docker for windows + ubuntu18.04 . git command not found

Last updated at Posted at 2022-01-08

立てたばかりのubuntu環境でapt-get installしたいときは、まずapt-get updateが必要だよという話。

GitHubの楽しそうなコードを動かそうと思って、WindowsPCでDockerのubuntu18.04環境を立てた。

18.04
docker run -it --name <container_name> ubuntu:18.04

さっそく目当てのリポジトリを、コンテナ内にダウンロードしようと思いgitコマンドを使たところ次のようなエラーが出た。
bash: git:command not found

そうだ、git インストールしてないじゃん!
と思いながら、インストールするおなじみのコマンド
apt-get install git
を入力すると、以下のエラーが出る。
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package git

あれ、なんでやろ?と思いながら、いろいろサイトを回って、解決策を探すと以下を実行することで無事にgitをインストールすることができた。
apt-get update

立てたばかりのubuntu環境だと、パッケージをインストールするために、パッケージリストを一度更新し、パッケージインデックスファイルをダウンロードする必要があるようだ。
これによって、apt-get install諸々を利用できるようになる。

以下の記事を参照しました

IT資格マニアのエンジニア技術ブログ×英語:
https://chico-shikaku.com/2020/03/docker-ubuntu-git-command-not-found/

君は心理学者なのか?
https://karoten512.hatenablog.com/entry/2018/01/09/003330

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