Cannot connect to internet from inside a docker container in Ubuntu VM

Gabriel Castillo 0 Reputation points
2024-12-18T05:39:59.78+00:00

Hi,

I am trying to access internet from inside docker containers in an Ubuntu VM. According to the azure documentation found here: https://learn.microsoft.com/en-us/azure/virtual-network/deploy-container-networking#deploy-plug-in-for-docker-containers

I deployed the plugin, also created the container using the command ./docker-run.sh ... but still there is no internet access from inside the container, I am not able to run any commands in the container like ping, curl, apt-get, etc so Internet is not yet enabled in the docker container.

Is there a way that I can troubleshoot or test that conectivity to internet from inside the docker container?

Azure Container Registry
Azure Container Registry
An Azure service that provides a registry of Docker and Open Container Initiative images.
483 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,411 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Abiola Akinbade 23,520 Reputation points
    2024-12-18T11:46:21.28+00:00

    Hello Gabriel Castillo,

    Thanks for your question.

    Try the following as torubleshooting steps to pindown the issue:

    Check Docker network configuration

    docker network ls
    docker network inspect bridge
    

    Inspect the specific container's network details

    docker inspect <container_name>

    Verify DNS configuration inside the container:

    cat /etc/resolv.conf

    Test network connectivity from the host itself to see if its a host issue

    ping 8.8.8.8
    ping google.com
    

    Also see the stackoverlow post for an ubuntu machine https://stackoverflow.com/questions/73313328/how-to-troubleshoot-docker-network-issues

    You can mark it 'Accept Answer' and 'Upvote' if this helped you

    Regards,

    Abiola

    0 comments No comments

  2. Nikhil Duserla 4,515 Reputation points Microsoft Vendor
    2025-01-20T15:02:37.3633333+00:00

    Hi @Gabriel Castillo,

    Thank you for your patience.Run command: sudo su

    Once docker image building is finished: docker build -t <imagename> . then run the Docker Container: docker run -d -p 80:80 --name <containername> <imagename>

    Run command: docker exec -it <containerID> /bin/bash

    apt-get update

    apt install iputils-ping

    Try ping google.com and check whether you are able to connect.

    If you have any further queries, do let us know. We are happy to assist you.


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.