Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/config_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type DockerNetworkConfiguration struct {
// with any other interfaces in use by Docker or on the system.
Interface string `default:"172.18.0.1" json:"interface" yaml:"interface"`

// DisableInterfaceBinding determines whether containers should bind to a specific
// interface. If true, containers will bind to all interfaces.
DisableInterfaceBinding bool `default:"false" json:"disable_interface_binding" yaml:"disable_interface_binding"`

// The DNS settings for containers.
Dns []string `default:"[\"1.1.1.1\", \"1.0.0.1\"]"`

Expand Down
10 changes: 10 additions & 0 deletions environment/allocations.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,23 @@ func (a *Allocations) Bindings() nat.PortMap {
// server to operate on a local address while still being accessible by other containers.
func (a *Allocations) DockerBindings() nat.PortMap {
iface := config.Get().Docker.Network.Interface
disableBinding := config.Get().Docker.Network.DisableInterfaceBinding

out := a.Bindings()
// Loop over all the bindings for this container, and convert any that reference 127.0.0.1
// to use the pterodactyl0 network interface IP, as that is the true local for what people are
// trying to do when creating servers.
for p, binds := range out {
for i, alloc := range binds {
// If interface binding is disabled, set HostIP to empty string
if disableBinding {
out[p][i] = nat.PortBinding{
HostIP: "",
HostPort: alloc.HostPort,
}
continue
}

if alloc.HostIP != "127.0.0.1" {
continue
}
Expand Down