124

I'm trying to download a Debian package inside a Ubuntu container as follows:

sudo docker run ubuntu:14.04 wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.8.2-omnibus.1-1_amd64.deb

I get

exec: "wget": executable file not found in $PATH

I've already installed wget with docker as follows:

run ubuntu:14.04 apt-get install wget

How can I download a file?

3 Answers 3

181

You need to install it first. Create a new Dockerfile, and install wget in it:

FROM ubuntu:14.04
RUN  apt-get update \
  && apt-get install -y wget \
  && rm -rf /var/lib/apt/lists/*

Then, build that image:

docker build -t my-ubuntu .

Finally, run it:

docker run my-ubuntu wget https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.8.2-omnibus.1-1_amd64.deb
4
  • 13
    @Nachbar90 Each docker run command runs in an isolated container, so, whatever you installed in the first container isn't going to be present in the second container. You should probably read up a bit more on what containers are and how they work. Mar 5, 2015 at 18:38
  • 1
    How can you forward the result file of the last run to your local file system?
    – hhh
    Jul 17, 2018 at 15:58
  • It works fine but I wanted to ask about the package version. Otherwise, it doesnt pass the docker lint . Oct 5, 2020 at 19:11
  • 2
    Hi @ThomasOrozco. Why do you remove this folder /var/lib/apt/lists ?
    – Yairopro
    Aug 29, 2021 at 20:15
52

I had this problem recently where apt install wget does not find anything. As it turns out apt update was never run.

apt update
apt install wget

After discussing this with a coworker we mused that apt update is likely not run in order to save both time and space in the docker image.

2
  • 1
    had installed docker ubuntu container by simply doing docker pulll ubuntu and later into bash, got a "apt not found issue". This worked for me .thanks
    – veritas
    Oct 17, 2020 at 11:35
  • so helpful! I did this in centos7 docker container to get ping command working. Thanks! Jan 4, 2022 at 11:12
6

If you're running ubuntu container directly without a local Dockerfile you can ssh into the container and enable root control by entering su then apt-get install -y wget

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.