简体   繁体   English

在docker linux容器上安装netstat

[英]Installing netstat on docker linux container

I want to install netstat on my Docker container. 我想在我的Docker容器上安装netstat

I looked here https://askubuntu.com/questions/813579/netstat-or-alternative-in-docker-ubuntu-server-16-04-container so I'm trying to install it like this: 我看了这里https://askubuntu.com/questions/813579/netstat-o​​r-alternative-in-docker-ubuntu-server-16-04-container所以我试图像这样安装它:

apt-get install net-tools

However, I'm getting: 但是,我得到了:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package net-tools

So how can I install netstat ? 那么如何安装netstat呢?

You need to run apt-get update first to download the current state of the package repositories. 您需要先运行apt-get update来下载软件包存储库的当前状态。 Docker images do not include this to save space, and because they'd likely be outdated when you use it. Docker镜像不包含此项以节省空间,并且因为它们在您使用时可能会过时。 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: 如果您在Dockerfile中执行此操作,请确保将其保留为单个RUN命令,以便层的缓存不会使用新的软件包安装请求缓存旧版本的update命令:

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

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. netstat由net-tools软件包提供,默认情况下,net-tools可能不会安装在Ubuntu 16.04的Docker镜像中,以保持图像大小尽可能小。 Execute the following commands inside docker container: 在docker container中执行以下命令:

apt update
apt install net-tools

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM