简体   繁体   中英

Docker Transparent Network and port mapping

I am trying to get a WCF application running in a docker windows container.

I have played around with the different types of networking for a docker windows container. Seems there are two main options NAT and Transparent.

NAT is the default, and easily supports the -p 8080:80 type syntax to map a port. However, NAT blocks me from accessing anything outside the computer. (Meaning I cannot connect to other network resources.)

Transparent works great for accessing my network resources. But when I try to run it with -p 8080:80 it gives the following error:

failed to create endpoint distracted_gates on network basic: hnsCall failed in Win32: 
Port mapping is not supported on the given network. (0x803b0016).

Seems "Port mapping is not supported" on Transparent networks.

So, this leads to my question:

How do I specify a port to connect to my windows service using a Transparent network? (or is there a better way that I have not understood.)

Note: In case it is relevant, here is my docker run command (that gives the above error message):

docker run --network myTransparentNetwork --security-opt "credentialspec=file://mygMSA.json" -d -p 8080:80 myContainerImage:myTag

There is no need to map ports in a bridge (linux) or transparent (windows) networks. The requirement in this scenario is to make the use of the EXPOSE keyword within your Dockerfile.

The EXPOSE keyword in most of the scenarios (where NAT is used) are more useful for documentation purposes once you still have to map your -p hostPort:containerPort .

See below an example of the EXPOSE keyword in the Dockerfile:

#document ports that are mandatory
EXPOSE 8080 8090 9000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM