0

I want to create a jenkins image with a dockerfile. Docker is running (tried it with the hello-world image).

My Dockerfile:

FROM jenkins:latest USER root RUN apt-get update && apt-get install -y build-essentials USER jenkins 

I want to build an image with this command

sudo docker build -t "jenkins_master" . 

But i always get this error:

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

i've tried:

  • sudo service docker restart

  • sudo rm /var/lib/apt/lists/* -vf

But nothing works. I am using Ubuntu 16.04 LTS

2 Answers 2

4

You need to remember that these commands are running within the Docker container itself when you are building your Docker image. Therefore running commands on your local machine is unlikely to resolve the issue.

I think the package is called build-essential and not build-essentials (notice you have the extra 's' on the end of the package name).

Therefore changing your Dockerfile to read:

FROM jenkins:latest USER root RUN apt-get update && apt-get install -y build-essential USER jenkins 

Should fix it.

Sign up to request clarification or add additional context in comments.

Comments

0

From the docs

Always combine RUN apt-get update with apt-get install in the same RUN statement, for example

RUN apt-get update && apt-get install -y package-bar

(...)

Using apt-get update alone in a RUN statement causes caching issues and subsequent apt-get install instructions fail.

1 Comment

i changed it (see edited entry above) but i got the same error message

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.