====== Docker - Networking - Ping command not found ======
===== Check if ping works =====
Run a Docker container with Ubuntu:
docker run -it ubuntu /bin/bash
Then try a ping:
ping somesite.com
bash: ping: command not found
----
===== Install ping =====
Docker images are pretty minimal, but you can install ping in the official Ubuntu docker image via:
apt-get update
apt-get install iputils-ping
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 etc.
**apt-get** fails with Temporary failure resolving 'security.ubuntu.com' obviously because networking is not present.
----
===== Example Dockerfile for Ubuntu with ping =====
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
----