立てたばかりのubuntu環境でapt-get installしたいときは、まずapt-get update
が必要だよという話。
GitHubの楽しそうなコードを動かそうと思って、WindowsPCでDockerのubuntu18.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