How can I check if my extra_hosts configuration is working?
version: '3.5'
services:
nginx:
image: nginx:stable
extra_hosts:
- "host.docker.internal:host-gateway"
I tried docker exec nginx /bin/sh -c 'ping host.docker.internal'
but got /bin/sh: 1: ping: not found
Is there some kind of ping alternative available in the nginx docker image?
Testing on Ubuntu 20.04.3 LTS host, with docker version 20.10.11 and docker-compose version 1.29.2.
2
Answers
nginx image does not come with ping command, you can add a busybox to test in and out:
Always use sidecar container & do not overwhelm the main image:
k8s community provides a good image for network debugging which includes almost all famous CLIs : dig, nslookup, ping,.etc
Use it the same way the busybox way explained by gohm’c