Reputation: 125
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
Upvotes: 0
Views: 926
Reputation: 5056
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.
Upvotes: 4
Reputation: 2685
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.
Upvotes: 0