Replies: 1 comment
-
this.container = await docker.createContainer({
Tty: true,
Image: "waterdogpe/waterdogpe:latest",
name: "proxy",
Hostname: "proxy",
ExposedPorts: {
["19132/udp"]: {}, // used container port
["19132/tcp"]: {} // used container port
},
NetworkingConfig: {
EndpointsConfig: {
my_internal_net: {
Aliases: ["waterdogpe"]
}
}
},
HostConfig: {
PortBindings: {
["19132/tcp"]: [{ HostPort: this.port+"/tcp" }], // this.port => is the outside port
["19132/udp"]: [{ HostPort: this.port+"/udp" }] // this.port => is the outside port
}
}
}); This is my code of binding the container to a host port. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to expose a port from a container to be accessible externally, However the container itself should only have access to the internal network and nothing more.
I had assumed this would be possible with Exposing the ports (8080:8080) and then applying the network.
Code looks as follows
Without the
NetworkMode
option set to theno_internet
network then the container is created with the correct port bindings and has network access and functions as intendedIf I specify the
NetworkMode
The container doesn't do any port bindings.This is kinda important in the setup as Clients will have access to the container via the Port exposure, however we don't want them accessing the outer network through this just the internal network. Unless theres any alternative way of achieving this.
Without the
no_internet
NetworkWith the
no_internet
Network AppliedBeta Was this translation helpful? Give feedback.
All reactions