Docker - Ubuntu - bash: ping: command not found

前端 未结 7 2195
走了就别回头了
走了就别回头了 2020-12-07 07:15

I\'ve got a Docker container running Ubuntu which I did as follows:

docker run -it ubuntu /bin/bash

however it doesn\'t seem to have

7条回答
  •  心在旅途
    2020-12-07 07:59

    Generally people pull the official image of Ubuntu/CentOS but they don't realize that these images are minimal and doesn't have any thing on the top of that.

    For Ubuntu, this image is built from official rootfs tarballs provided by Canonical. Given that it is a minimal install of Ubuntu, this image only includes the C, C.UTF-8, and POSIX locales by default.

    One can install net-tools (includes ifconfig, netstat), ip-utils(includes ping) andy other likes curl etc on container and can create image from container or can write Dockerfile that will install these tool while creating image.

    Below is Dockerfile example, while creating image from this it will include these tools:

    FROM vkitpro/ubuntu16.04
    RUN     apt-get  update -y \
    && apt-get upgrade -y \
    && apt-get install iputils-ping -y \
    && apt-get install net-tools -y \
    CMD bash
    

    or launch container from base image and install these utilities on container and then commit to image. docker commit -m "any descriptive message" container_id image_name:lattest

    That image will have all thing installed.

提交回复
热议问题