Host shoots first, just like Han.

Presto! What is the port in the host that is mapped onto the port in the container?

docker run -p 12345:54321 ...

Yep, port 12345 in the host is mapped onto port 54321 in the container. You have just been awarded a… Bravo!

Fact is that I keep forgetting it. I hope to remember it better with Host shoots first, just like Han.

On a more serious note, I found a very interesting article: A Brief Primer on Docker Networking Rules: EXPOSE, -p, -P, –link, which I strongly recommend.

Among the rest, it provides this nugget:

The -p flag can take a few different formats:

ip:hostPort:containerPort  | ip::containerPort \
  | hostPort:containerPort | containerPort

So it turns out I’ve always been using the third form and never knew about it!