且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Docker - Ubuntu - bash: ping: 命令未找到

更新时间:2022-05-21 22:31:26

Docker 镜像非常小,但您可以通过以下方式在您的官方 ubuntu docker 镜像中安装 ping:

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

您的图像可能不需要 ping,而只想将其用于测试目的.上面的例子会帮助你.

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

但是如果您需要 ping 存在于您的图像中,您可以创建一个 Dockerfilecommit 将上述命令运行到的容器一张新图片.

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

提交:

docker commit -m "Installed iputils-ping" --author "Your Name <name@domain.com>" ContainerNameOrId yourrepository/imagename:tag

Dockerfile:

Dockerfile:

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

请注意创建 docker 镜像的***实践,例如之后清除 apt 缓存文件等.

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