【问题标题】:Installing netstat on docker linux container在 docker linux 容器上安装 netstat
【发布时间】:2017-06-17 02:30:15
【问题描述】:

我想在我的 Docker 容器上安装 netstat

我在这里查看https://askubuntu.com/questions/813579/netstat-or-alternative-in-docker-ubuntu-server-16-04-container,所以我尝试像这样安装它:

apt-get install net-tools

但是,我得到:

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

那么我该如何安装netstat

【问题讨论】:

    标签: linux docker netstat


    【解决方案1】:

    netstat 由 net-tools 包提供,Ubuntu 16.04 的 Docker 镜像中可能默认未安装 net-tools,以保持镜像大小尽可能小。 在 docker 容器中执行以下命令:

    apt update
    apt install net-tools
    

    【讨论】:

      【解决方案2】:

      您需要先运行apt-get update 以下载软件包存储库的当前状态。 Docker 映像不包含此内容是为了节省空间,并且因为当您使用它时它们可能已经过时了。如果您在 Dockerfile 中执行此操作,请确保将其保留为单个 RUN 命令,以便层的缓存不会缓存更新命令的旧版本和新的软件包安装请求:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-09-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-11
        • 1970-01-01
        • 2023-01-18
        相关资源
        最近更新 更多