Docker - Ubuntu - bash: ping: command not found [closed]
![Docker - Ubuntu - bash: ping: command not found [closed]](/images/posts/docker-ubuntu-ping-not-found.png)
TLDR
If you see bash: ping: command not found in an Ubuntu-based Docker container, install the iputils-ping package using apt-get install.
The ping command is often used to test network connectivity, but it may not be available in minimal Ubuntu-based Docker images. This guide explains how to resolve the issue and why it happens.
Why Is ping Missing?
Minimal Docker images, like ubuntu:latest, exclude many utilities to keep the image size small. The ping command is part of the iputils-ping package, which is not installed by default.
Installing ping in a Docker Container
To install ping, you need to update the package list and install the iputils-ping package:
# Start a shell in the container
docker exec -it <container_name_or_id> bash
# Update package list
apt-get update
# Install iputils-ping
apt-get install -y iputils-ping
Now you can use the ping command inside the container.
Making the Change Persistent
If you frequently need ping in your containers, add it to your Dockerfile:
FROM ubuntu:latest
RUN apt-get update && apt-get install -y iputils-ping
Build the image:
docker build -t ubuntu-with-ping .
This way, every time you run a container from this image, ping will be available. For example:
docker run --rm -it ubuntu-with-ping bash
You can now use ping without any issues.
Best Practices
- Use minimal images for production to reduce attack surface.
- Only install tools like
pingwhen needed for debugging or testing. - Document any manual changes to containers.
By following these steps, you can quickly resolve the ping: command not found error and ensure your containers have the tools you need.
Good luck with your project!
Related Resources
- Docker Alpine: How to Use Bash: install tools in Alpine images
- PS Command Not Working in Docker: install missing utilities
- How to Use Sudo in Docker Container: permissions in containers
- Introduction to Docker Guide: Docker basics
Try it hands-on
Run the commands from this article in the browser. Nothing to install.
Docker Terminal Simulator
Practice Docker commands in an interactive browser terminal. Learn images, containers, logs, exec, Dockerfile builds, volumes, networks, and Docker Compose with a live Docker daemon visualization.
How Docker Works Under the Hood
Watch what really happens when you run docker run -p 8080:80 nginx, one layer at a time. Step down the whole stack: the CLI, the daemon, the registry pull, containerd, the OCI runtime bundle, runc, the running container, and the shared Linux kernel. Every stage shows the real low-level command you can run yourself, so it doubles as a tour of the primitives that make a container: namespaces, cgroups, and runc. A container is not a small VM, and this shows you why.
We earn commissions when you shop through the links below.
Svix
Webhooks as a service
Svix Dispatch sends your webhooks for you: retries with exponential backoff, signed payloads, idempotency keys, and a delivery log your customers can see.
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a SponsorTags
Found an issue?
Related Posts
Also worth your time on this topic
How to Access Host Port from Docker Container
Learn how to access a host machine's port from a Docker container using network configurations and best practices.
Docker Multi-Stage Build Optimization
Learn to create efficient Docker images using multi-stage builds to reduce image size and improve security.
60 minutes
CI/CD Pipeline Setup Checklist
Step-by-step checklist for a production-ready CI/CD pipeline: source control, builds, tests, security scans, deploy gates, secrets, and rollback paths.
1-2 hours