简体   繁体   中英

Docker Debian install fails

I have a Dockerfile that works, but if I add any new dependencies to the apt-get install command, it fails. For example, this works:

FROM debian:stable

RUN apt-get update

RUN apt-get install -y \
    python \
    ...
    apache2

But if I try this, it fails:

FROM debian:stable

RUN apt-get update

RUN apt-get install -y \
    python \
    ...
    apache2
    python-mysqldb

I can replace python-mysqldb with anything else, git-core , for example, and it will still fail with the same error message:

Unable to correct missing packages.
E: Failed to fetch http://security.debian.org/pool/updates/main/l/linux/linux-libc-dev_3.16.7-ckt11-1+deb8u5_amd64.deb  404  Not Found [IP: 149.20.20.6 80]

E: Aborting install.

Any thoughts on why adding a new dependency causes the failure and how to fix it?

I've found that you need to join the update & install command into the same RUN block.

eg:

RUN apt-get update \
 && apt-get install -y \
    python \
    ...
    apache2 \
    python-mysqldb

According to this post describing the issue

By default, Docker cache your commands to reduce time spent building images. Unless there was any change before such commands (or at the same line).

Meanwhile, I notice that the AWS examples separate them, as you have them. So I dunno if it works different there. Maybe they disable the cache by default.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM