Search code examples
gitdockerubuntu-14.04dockerfile

Unable to locate packages in docker container


While trying to build my repository inside a docker container, I need to install git:

FROM ubuntu:14.04
RUN apt-get update
RUN apt-get upgrade
RUN apt-get clean
RUN apt-get install -y git

to build the container i run the following command:

sudo docker build .

I get the following error on every package i try to install:

 E: Unable to locate package git
 The command '/bin/sh -c apt-get install -y git' returned a non-zero code: 100

All the answers i found were claiming that i need to run apt-get update first, which i do.

EDIT:

Tried to run all of the commands in one line:

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

which yielded the following error:

Err http://archive.ubuntu.com trusty InRelease
Err http://archive.ubuntu.com trusty-updates InRelease
Err http://archive.ubuntu.com trusty-security InRelease
Err http://archive.ubuntu.com trusty Release.gpg
Could not resolve 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease  
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package git
The command '/bin/sh -c apt-get update && apt-get install -y git' returned a non-zero code: 100

Solution

  • From your updated output, you show your apt-get update is failing, DNS resolution failed. This is a network connectivity issue you need to resolve first before you'll be able to build images that pull packages from the network.