Document using port 0 for host port to let docker assign an available high port
thenewguy opened this issue · comments
thenewguy commented
I happened to guess correctly, but an example like this would probably be useful:
ports =
0:631/TCP
since the docs mention it is up to the user to make sure ports are available on the host. The 0 value lets docker assign the host port automatically
Dan Crosta commented
Hm, so this is when you don't want to expose all ports, but also don't want
to pick a particular port? Yeah, that seems reasonable.
thenewguy commented
Exactly - the container I am working with in #115 doesn't expose ports. So I have to tell it which to expose. However, I want docker to assign the host port so that I can run it on an arbitrary test runner without worrying about host configuration
Then I can still use it like this:
os.getenv('PRINTER_HOST', 'localhost')
os.getenv('PRINTER_631_TCP_PORT', '631')