dockernetwork-programmingdocker-network

How can I get the network driver that a particular docker container is using?


I'm trying to debug some docker containers that aren't allowing outgoing connections. The docker documentation says that allowing outgoing connections is the default behavior of the default bridge network driver, but that the none driver does not allow outgoing connections. I'd like to be able to check which network driver these containers are using, but I haven't been able to find the right switches in docker ps (or any other command) that would allow me to do this.

How can I get the network driver for a particular docker container from the command line?


Solution

  • Use docker container inspect to view the NetworkMode attribute of the container:

    docker container inspect <container> --format '{{ .HostConfig.NetworkMode }}'
    

    This will either be: