Add a way to expose a port without publishing

Use the existing "expose" section of container yaml files, which has always been publishing ports.
Expose a port if a single port number is specified (`80`).
Publish if a port mapping is specified (`"80:80"`, `"127.0.0.1:20080:80"`).
This commit is contained in:
Neil Lalonde 2019-03-07 14:49:24 -05:00
parent 024ebc4037
commit 16fb17cf51
2 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ expose:
- "127.0.0.1:20080:80"
```
Expose port 22 inside the container on port 2222 on ALL local host interfaces. In order to bind to only one interface, you may specify the host's IP address as `([<host_interface>:[host_port]])|(<host_port>):<container_port>[/udp]` as defined in the [docker port binding documentation](http://docs.docker.com/userguide/dockerlinks/)
Publish port 22 inside the container on port 2222 on ALL local host interfaces. In order to bind to only one interface, you may specify the host's IP address as `([<host_interface>:[host_port]])|(<host_port>):<container_port>[/udp]` as defined in the [docker port binding documentation](http://docs.docker.com/userguide/dockerlinks/). To expose a port without publishing it, specify only the port number (e.g., `80`).
#### volumes:

View File

@ -425,7 +425,7 @@ RUBY
p e
end
end
puts ports.map {|p| "-p\n#{p}"}.join("\n")
puts ports.map { |p| p.to_s.include?(':') ? "-p\n#{p}" : "--expose\n#{p}" }.join("\n")
RUBY
tmp_input_file=$(mktemp)