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?

More than 3 years have passed since last update.

Dockerfileでapt-get updateやapt-get upgradeを実行するとエラーになる

Posted at

実行環境

・ホストOS: Windows10 Home 2004
・ゲストOS: WSL2 Ubuntu20.04
・docker ver20.10.3

エラー内容

FROM python:latest

RUN mkdir /code
WORKDIR /code

RUN apt-get update && apt-get  upgrade\
    apt-get install -y vim

COPY requirements.txt /tmp/
RUN pip install --upgrade pip \
    pip install -r /tmp/requirements.txt

上のようなDockerfileをビルドしようとしたところ、次のようなエラーが発生した

E: Unable to locate package apt-get
E: Unable to locate package install

解消方法

・apt-get upgradeを削除する
・apt-getをaptに書き換える
この二箇所の変更でエラーが発生しなくなった。

FROM python:latest

RUN mkdir /code
WORKDIR /code

RUN apt update && apt install -y vim

COPY requirements.txt /tmp/
RUN pip install --upgrade pip \
    pip install -r /tmp/requirements.txt

理由は今のところ分からないので、後で調べて追記します。

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?