Comments (3)
Alright here is how you do it:
const POSTGRES_DEFAULT_PORT: u16 = 5432;
fn myfunc(other_port: u16) {
let port = other_port.to_string();
let exposed_ports = Some(hashmap! {POSTGRES_DEFAULT_PORT => hashmap!{}});
let host_config = Some(HostConfig {
port_bindings: Some(hashmap! {
POSTGRES_DEFAULT_PORT.to_string() => Some(vec![PortBinding {
host_ip: Some("127.0.0.1".to_string()),
host_port: Some(port),
}]),
}),
..Default::default()
});
let config = Config {
image: Some(POSTGRES_IMAGE),
exposed_ports,
host_config,
..Default::default()
};
}
In short, put the inner port in exposed ports and as the key in port bindings, use the outer port in the value of port bindings.
from bollard.
You don't actually need the exposed_ports
field to publish a port, only the port_bindings
map within host_config
.
exposed_ports
is equivalent to the docker run --expose
flag or Dockerfile EXPOSE
statement - it doesn't actually do anything and is basically just a hint for clients regarding which ports should be published.
from bollard.
Ah good to know, ty!
from bollard.
Related Issues (20)
- Stream doesn't close after exec log
- Problems Connecting w/ HTTP HOT 1
- How to import images from tar using stream HOT 3
- docker manifest inspect
- Add Docker Socket availability check during connection creation HOT 3
- Unexplained race condition in v0.16 causing "runtime dropped the dispatch task" HOT 8
- Support for multiple image build tags? HOT 1
- code is inactive due to #[cfg] directives: feature = "buildkit" is disabled HOT 4
- How to specify multi-stage build target in build_image? HOT 1
- Looking for help: Created container seem to be not listen to export and published port HOT 1
- Add a `Docker::connect_with_url()` method HOT 4
- Generic strategy for health checking a container? HOT 1
- Unclear error when docker is not running HOT 2
- UpdateContainerOptions has i_ops and cp_us instead of iops and cpus HOT 2
- Is it possible to use list_containers without type params? HOT 2
- Custom Build Outputs `--output` HOT 10
- Cutting out a new minor release HOT 1
- Unable to anonymously pull an image from ghcr.io when using BuildKit HOT 7
- Feature request: allow HTTP request customizations
- Both ring and aws-lc-rs provider are enabled HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bollard.