To enable ping access in a Docker container on RHEL/CentOS Linux 7, you can use the following steps:
- Start a new Docker container:
docker run -it --name <container_name> <image_name> /bin/bash
- Install the
iputils
package inside the Docker container:
yum install iputils -y
- Modify the firewall rules to allow ICMP (ping) traffic:
firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="<container_ip_address>" accept'
firewall-cmd --reload
- Verify that ping access is enabled by pinging a remote host from inside the container:
ping <remote_host_ip_address>
Note: Replace <container_name>
, <image_name>
, <container_ip_address>
, and <remote_host_ip_address>
with the appropriate values for your environment.