Docker-Ubuntu-bash:ping:找不到命令 [英] Docker - Ubuntu - bash: ping: command not found

查看:466
本文介绍了Docker-Ubuntu-bash:ping:找不到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行Ubuntu的Docker容器,其操作如下:

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

docker run -it ubuntu /bin/bash

但是似乎没有ping.例如

bash: ping: command not found

我需要安装吗?

似乎缺少了一个非常基本的命令.我尝试了whereis ping,它什么也没报告.

Seems a pretty basic command to be missing. I tried whereis ping which doesn't report anything.

推荐答案

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 dont need ping 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 in to 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 after and etc.

这篇关于Docker-Ubuntu-bash:ping:找不到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆