Installing netstat on docker linux container

36,543

Solution 1

You need to run apt-get update first to download the current state of the package repositories. Docker images do not include this to save space, and because they'd likely be outdated when you use it. If you are doing this in a Dockerfile, make sure to keep it as a single RUN command so that caching of the layers doesn't cache an old version of the update command with a new package install request:

RUN apt-get update \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y \
    net-tools \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*

Solution 2

netstat is provided by the net-tools package,net-tools is probably not installed by default in the Docker image for Ubuntu 16.04 to keep the image size as small as possible. Execute the following commands inside docker container:

apt update
apt install net-tools
Share:
36,543

Related videos on Youtube

bsky
Author by

bsky

Updated on August 24, 2020

Comments