Docker - Ubuntu - bash: ping: command not found

前端 未结 7 2204
走了就别回头了
走了就别回头了 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:58

    This is the Docker Hub page for Ubuntu and this is how it is created. It only has (somewhat) bare minimum packages installed, thus if you need anything extra you need to install it yourself.

    apt-get update && apt-get install -y iputils-ping
    

    However usually you'd create a "Dockerfile" and build it:

    mkdir ubuntu_with_ping
    cat >ubuntu_with_ping/Dockerfile <<'EOF'
    FROM ubuntu
    RUN apt-get update && apt-get install -y iputils-ping
    CMD bash
    EOF
    docker build -t ubuntu_with_ping ubuntu_with_ping
    docker run -it ubuntu_with_ping
    

    Please use Google to find tutorials and browse existing Dockerfiles to see how they usually do things :) For example image size should be minimized by running apt-get clean && rm -rf /var/lib/apt/lists/* after apt-get install commands.

提交回复
热议问题