Can't access exposed ports for running docker containers on vm machine via public IP

Mohamed 0 Reputation points
2025-02-07T23:33:47.1766667+00:00

I am currently running multiple Docker containers on an Azure VM, including a MySQL container and several other services. However, I am experiencing several issues with network connectivity that I need assistance with:

Docker Container Connectivity: My containers are unable to access the MySQL container, despite the MySQL container being healthy and running. Additionally, containers that are not dependent on MySQL cannot be accessed via their exposed ports.

Internet Access: The containers on the VM cannot access the internet, which is preventing certain operations from functioning as expected, such as installing packages or performing external API calls.

Port Access via Public IP: Although the necessary ports are open in the Azure inbound security rules and the containers are running, I am unable to access the services through the public IP of the Azure VM.

Troubleshooting Steps Taken:

  • Verified that there are no apparent issues with the containers or the network.
  • Used Azure's "Verify IP Flow" tool to confirm that the flow between private and public IPs is working correctly, and that the necessary ports are accessible.
  • Checked the Docker container's network settings, but was unable to find a solution.

Request: I would greatly appreciate assistance in resolving these issues. Specifically, I need help ensuring that:

  • The containers can access the MySQL container and the internet.
  • The exposed ports for the services on the containers are reachable from external networks via the public IP.

Thank you for your help and support!I am currently running multiple Docker containers on an Azure VM, including a MySQL container and several other services. However, I am experiencing several issues with network connectivity that I need assistance with:

Docker Container Connectivity: My containers are unable to access the MySQL container, despite the MySQL container being healthy and running. Additionally, containers that are not dependent on MySQL cannot be accessed via their exposed ports.

Internet Access: The containers on the VM cannot access the internet, which is preventing certain operations from functioning as expected, such as installing packages or performing external API calls.

Port Access via Public IP: Although the necessary ports are open in the Azure inbound security rules and the containers are running, I am unable to access the services through the public IP of the Azure VM.

Troubleshooting Steps Taken:

  • Verified that there are no apparent issues with the containers or the network.
  • Used Azure's "Verify IP Flow" tool to confirm that the flow between private and public IPs is working correctly, and that the necessary ports are accessible.
  • Checked the Docker container's network settings, but was unable to find a solution.

Request: I would greatly appreciate assistance in resolving these issues. Specifically, I need help ensuring that:

  • The containers can access the MySQL container and the internet.
  • The exposed ports for the services on the containers are reachable from external networks via the public IP.

Thank you for your help and support!

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,354 questions
{count} votes

1 answer

Sort by: Most helpful
  1. anashetty 2,120 Reputation points Microsoft Vendor
    2025-02-10T07:52:01.57+00:00

    Hi Mohamed,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.Please try below troubleshooting steps:
    Issue: Containers cannot access the MySQL container or other services via exposed ports.
    See that all containers are on the same Docker network. create a custom bridge network and attach all containers to it, verify that all containers are connected to it.
    Check that the MySQL container is listening on the correct interface (0.0.0.0)

    Issue: Containers cannot access the internet.
    Verify the DNS settings on the host VM, If the DNS settings are incorrect, update them or specify custom DNS servers in the Docker daemon configuration then restart docker daemon after making changes.
    Check that the Azure VM itself has internet access, If the host cannot access the internet, check the VM's network configuration and Azure's outbound rules.

    Issue: Services on the containers are not reachable via the Azure VM's public IP.
    Check the NSG rules in the Azure portal, inbound ports are correctly setup.
    Ensure the containers are correctly binding to the host's ports, verify the ports are correctly bound. Once check the container logs.

    If you have any further queries, please let me know. If it is helpful, please click Upvote.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.