====== Docker - Networking - Ping command not found ======
Docker container running Ubuntu which I did as follows:
docker run -it ubuntu /bin/bash
Then trying a ping:
ping somesite.com
bash: ping: command not found
----
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 don't 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 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