Create Transparent Network in Windows Container
In this blog, we will show you how to create a transparent network in windows container using docker commands.
INTRODUCTION
The transparent network allows containers to be on the same network as container host. We need use both PowerShell and docker commands to configure the transparent network for containers.
SETTING UP TRANSPARENT NETWORK
- First, we need to stop the docker service using below command.
stop-service docker
- Delete the existing network before creating the transparent network. Execute the below command.
Get-ContainerNetwork | Remove-ContainerNetwork
- Open C:\ProgramData\docker\config folder.
- Open the daemon.json file and add the below lines.
{
“bridge” : “none”
}
- The above daemon file informs to docker engine that not to built the NAT network while starting the docker service.
- save and close the file.
- Start the docker service using start-service docker command.
- There will not be any container network if you execute Get-ContainerNetwork command.
CREATING TRANSPARENT NETWORK
- To create a transparent network, use the below command.
docker network create –d transparent TNET
docker network – Use to create docker networks.
Create – It’s a sub-command to create a network.
-d – which driver to use to create a network. We need to give it as transparent.
TNET – Name for the network.
Note : docker network create command is the equivalent to new-containernetwork
- Type Get-ContainerNetwork to the information about the network.
- If we run docker network ls command, you can find network driver information.
VERIFYING TRANSPARENT NETWORK
- Launch new container using the below command.
docker run -it –network=TNET microsoft/nanoserver
- once the container is up and running, type ipconfig to verify the IP settings
- The IP 192.168.233.97 is the physical network in our office. This container got the IP address from the physical DHCP server.
- Also, we will able to ping the internet domain.
VIDEO
Thanks for reading this blog. We hope it was useful for you to learn how to configure a transparent network for the container.
When I follow the steps in your document I find that my container does not pick up an IP. I confirmed that the nat driver provides an addressable IP. Am I missing something? Any suggestions would be appreciated.
Hi John,
Once you disable the bridge network through daemon.json file it looks for DHCP service in your environment. If it’s available then it will acquire an IP from that. Please make sure that you have a DHCP server running in your environment.
Regards,
Loges