How to run wget inside Ubuntu Docker image?

Marian Klühspies picture Marian Klühspies · Mar 5, 2015 · Viewed 107.4k times · Source

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?

Answer

Thomas Orozco picture Thomas Orozco · Mar 5, 2015

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