Docker error: Unable to locate package git

前端 未结 1 1281
深忆病人
深忆病人 2021-02-02 06:16

I\'m using an image nginx which is based on dockerfile/ubuntu. On attaching to the docker container\'s shell

docker exec -it 

        
1条回答
  •  别跟我提以往
    2021-02-02 06:52

    This is happening because the apt repository is not yet updated, it is common practice to clean your apt repositories and tmp files after creating an image, which your base image is probably doing.

    To fix this, you are going to want to run apt-get update prior to installing git, it is good practice to combine the update and install command at the same time to bust cache on the update if the install line changes:

    RUN apt-get update && apt-get install -y git
    

    Using -y is convenient to automatically answer yes to all the questions.

    0 讨论(0)
提交回复
热议问题