Docker - Ubuntu - bash: ping: command not found

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

    Docker images are pretty minimal, But you can install ping in your official ubuntu docker image via:

    apt-get update
    apt-get install iputils-ping
    

    Chances are you dont need ping your image, and just want to use it for testing purposes. Above example will help you out.

    But if you need ping to exist on your image, you can create a Dockerfile or commit the container you ran the above commands in to a new image.

    Commit:

    docker commit -m "Installed iputils-ping" --author "Your Name " ContainerNameOrId yourrepository/imagename:tag
    

    Dockerfile:

    FROM ubuntu
    RUN apt-get update && apt-get install -y iputils-ping
    CMD bash
    

    Please note there are best practices on creating docker images, Like clearing apt cache files after and etc.

提交回复
热议问题