SoFunction
Updated on 2025-04-11

The problem of external users not being able to access after Docker port mapping and the solution

After Docker port mapping, the external unit cannot access it

Possible problems:

Not working

  • The external unit must be in the same network segment as the host unit

2. The enantios docker container is not started

  • docker start container name/container ID

3. The firewall is isolated

  • Check the firewall status
firewall-cmd --state
  • Turn off the firewall
systemctl stop 
  • Firewall is prohibited from starting up
systemctl disable  
  • Firewall boots up
systemctl start firewalld
  • Firewall open mapped ports
firewall-cmd --zone=public --add-port=3306/tcp --permanent
#Restart the firewallfirewall-cmd --reload

4. IP forwarding is not enabled

  • Check whether it is turned on
# 1. Check whether it is turned on. If it is not equal to 1, it is not turned on.sysctl net.ipv4.ip_forward
# 2. Modify the file to openvim /etc/
#3, configuration = 1net.ipv4.ip_forward=1
# 4. Restart the network to make the configuration take effectsystemctl restart network
# 5. Check again if it is equal to 1sysctl net.ipv4.ip_forward

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.