Skip to content

Commit

Permalink
Add a way to expose a port without publishing
Browse files Browse the repository at this point in the history
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"`).
  • Loading branch information
nlalonde committed Mar 7, 2019
1 parent 024ebc4 commit 16fb17c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion launcher
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 16fb17c

Please sign in to comment.