How to run wget inside Ubuntu Docker image?

UbuntuDockerWget

Ubuntu Problem Overview


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?

Ubuntu Solutions


Solution 1 - Ubuntu

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

Solution 2 - Ubuntu

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.

Solution 3 - Ubuntu

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMarian KlühspiesView Question on Stackoverflow
Solution 1 - UbuntuThomas OrozcoView Answer on Stackoverflow
Solution 2 - UbuntuLincolnView Answer on Stackoverflow
Solution 3 - UbuntuiksnaeView Answer on Stackoverflow