简体   繁体   English

Docker构建在apt-get中失败

[英]Docker build fails in apt-get

I'm getting an error during build. 在构建期间出现错误。 I've seen many similar questions but nothing seems to solve this issue. 我见过许多类似的问题,但似乎没有任何解决办法。

I'm running Docker (Version 17.06.0-ce-mac18) on OS X El Capitan. 我在OS X El Capitan上运行Docker(版本17.06.0-ce-mac18)。

My Dockerfile is: 我的Dockerfile是:

FROM ubuntu:14.04
RUN apt-get update && apt-get install -y -q git

I'm getting Bad Request 400 error from one of git dependencies: 我从git依赖项之一收到Bad Request 400错误:

Get:38 http://archive.ubuntu.com/ubuntu/ trusty-updates/main patch amd64 2.7.1-4ubuntu2.3 [86.4 kB]
Fetched 7619 kB in 5s (1367 kB/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libx/libx11/libx11-data_1.6.2-1ubuntu2_all.deb  400  Bad Request [IP: 91.189.88.162 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update && apt-get install -y -q git' returned a non-zero code: 100

Any explanations or ideas for workaround? 任何解决方法的解释或想法?

I think the mirror being used is not reachable at the moment, You can try changing mirrors in for ubuntu from your docker file using sed . 我认为目前无法使用正在使用的镜像,您可以尝试使用sed从泊坞窗文件中为ubuntu更改镜像。

You can also use ubuntu's mirror protocol, which will fetch mirrors located within your country: 您还可以使用ubuntu的镜像协议,该协议将获取您所在国家/地区内的镜像:

FROM ubuntu:14.04
RUN sed -i -e 's/http:\/\/archive/mirror:\/\/mirrors/' -e 's/\/ubuntu\//\/mirrors.txt/' /etc/apt/sources.list
RUN apt-get update && apt-get install -y -q git

You can even specify a specific mirror you want to be used in the same way. 您甚至可以指定想要以相同方式使用的特定镜像。 For more information about apt mirrors refer to this post 有关apt镜像的更多信息,请参阅此文章

I think the problem come from the fact that you are using ubuntu:14.04 which is deprecated ( https://askubuntu.com/questions/731891/not-able-to-install-anything-and-update-on-ubuntu-14-10 ) 我认为问题来自于您正在使用的ubuntu:14.04( https://askubuntu.com/questions/731891/not-able-to-install-anything-and-update-on-ubuntu-14 -10

Can you try with FROM ubuntu ? 您可以尝试使用FROM ubuntu吗? This will use the latest ubuntu image, which is 16.04. 这将使用最新的ubuntu映像,即16.04。

EDIT: Ubuntu 14.04 is an LTS, so as pointed by @jwodder it should still be supported. 编辑:Ubuntu 14.04是一个LTS,因此@jwodder指出仍应支持它。 I would still try to use the latest LTS (16.04) with FROM ubuntu as it might be an easy fix. 我仍然会尝试将最新的LTS(16.04)与FROM ubuntu因为这可能是一个简单的解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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