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?

【Docker】古いDocker imageを使用した時にパッケージが見つからない

Posted at

はじめに

古いDocker imageを使用する際に、apt-getでインストールしたいパッケージが見つからない時の打開策について、既出の方法ですが備忘録として残します。

概要

  • 古いバージョンのPHP-apache の Docker imageでコンテナを作成したい
  • Dockerfile の RUN で apt-get install しようとするとパッケージが見つからない
  • Debian のバージョンが古くDocker imageで依存関係がサポートされていないため、アーカイブから参照するように設定する

古いバージョンのPHP-apache の Docker imageでコンテナを作成したい

下記の内容でDocker fileを作成

FROM php:5-apache

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

Dockerfile の RUN で apt-get install しようとするとパッケージが見つからない

build しようとすると下記のエラーが表示されます。

Err http://security.debian.org jessie/updates/main amd64 packages 404 not found
Err http://security.debian.org jessie-updates main amd64 packages 404 not found
Err http://security.debian.org jessie/main amd64 packages 404 not found

Debian のバージョンが古くDocker imageで依存関係がサポートされていないため、アーカイブから参照する

これは Docker image のバージョンが古くサポートが終了していることが原因のため、インストールしたいパッケージをアーカイブから参照する必要があります。

具体的には Dockerfile の RUN に

FROM php:5-apache

RUN echo "deb http://archive.debian.org/debian/ jessie main" > /etc/apt/sources.list \
    && echo "deb http://archive.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list \
    # 上2行を追加
    && apt-get update && apt-get install -y vim

コンテナ内にある /etc/apt/sources.list に書いてある情報を基にリソースを参照しているため、そこに追記してあげます。

メインの問題はこれで解決しますが、 実際に上記の内容で vim をインストールするには、コマンドのオプションに--force-yesをつけてあげる必要があります。

余談

Debianのコードネームはトイストーリーのキャラが由来みたいです。

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?