7

I installed ubuntu 14.04 virtual machine and run docker(1.11.2). I try to build sample image (here).

docker file :

FROM java:8 

# Install maven
RUN apt-get update  
RUN apt-get install -y maven
....

I get following error:

Step 3: RUN apt-get update
 --> Using cache
 --->64345sdd332
Step 4: RUN apt-get install -y maven
 ---> Running in a6c1d5d54b7a
Reading package lists...
Reading dependency tree...
Reading state information...
E: Unable to locate package maven
INFO[0029] The command [/bin/sh -c apt-get install -y maven] returned a non-zero code:100

enter image description here

following solutions I have tried, but no success.

  1. restarted docker here

  2. run as apt-get -qq -y install curl here :same error :(

how can i view detailed error message ? a any way to fix the issue?

Community
  • 1
  • 1

5 Answers5

5

you may need to update os inside docker before

try to run apt-get update first, then apt-get install xxx

Alongkorn
  • 3,968
  • 1
  • 24
  • 41
2

The cached result of the apt-get update may be very stale. Redesign the package pull according to the Docker best practices:

FROM java:8 

# Install maven
RUN apt-get update \
 && DEBIAN_FRONTEND=noninteractive \
    apt-get install -y maven \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/*  
BMitch
  • 231,797
  • 42
  • 475
  • 450
1

Based on similar issues I had, you want to both look at possible network issues and possible image related issues.

  • Network issues : you are already looking at proxy related stuff. Make sure also the iptables setup done automatically by docker has not been messed up unintentionnaly by yourself or another application. Typically, if another docker container runs with a net=host option, this can cause trouble.

  • Image issues : The distro you are running on in your container is not Ubuntu 14.04 but the one that java:8 was built from. If you took the java image from official library on docker hub, you have a hierarchy of images coming initially from Debian jessie. You might want to look the different Dockerfile in this hierarchy to find out where the repo setup is not the one you are looking at.

For both situations, to debug this, I recommand you run inside the latest image a shell to look the actual network and repo situation in your image. In your case

docker run -ti --rm 64345sdd332 /bin/bash

gives you a shell just before running your install maven command.

Yves Nicolas
  • 6,901
  • 7
  • 25
  • 40
0

I am currently working behind proxy. it failed to download some dependency. for that you have to mention proxy configuration in docker file. ref

but, now I facing difficulty to run "mvn", "dependency:resolve" due to the proxy, maven itself block to download some dependency and build failed.

thanks buddies for your great support !

Community
  • 1
  • 1
0

Execute 'apt-get update' and 'apt-get install' in a single RUN instruction. This is done to make sure that the latest packages will be installed. If 'apt-get install' were in a separate RUN instruction, then it would reuse a layer added by 'apt-get update', which could have been created a long time ago.

RUN apt-get update && \
    apt-get install -y <tool..eg: maven>

Note: RUN instructions build your image by adding layers on top of the initial image.

Nikita Jain
  • 669
  • 8
  • 11