Changing the container networking
We've seen a lot in this chapter about how to get our containers working smoothly and reliably. But what we haven't looked at is how to configure the networking. We've been using the -p
flag, but what does it do? And what else can we do with our container networking?
Getting started
We need our Windows Server 2019 server that's running containers.
How to do it…
Follow these steps to change the container networking:
- On your Windows server, open PowerShell as an Administrator.
- We don't need to do anything complicated to demonstrate this recipe, so let's just start by running the test IIS site:
docker run -d -p 8000:80 mcr.microsoft.com/windows/servercore/iis
- This starts our IIS container and makes it accessible on port
8000
. You can browse to it withhttp://localhost:8000
. - But what if we didn't want it running on port
8000
? After all, that's not a particularly convenient port...