v2.2.5 511b814

network-isolation.md RawHistoryFolder

Network Isolation

Isolate applications in separate Docker networks for enhanced security.

Configuration

[network_isolation]
enabled = true
network_prefix = "gordon"
dns_suffix = ".internal"

Options

Option Type Default Description
enabled bool false Enable per-app network isolation
network_prefix string "gordon" Prefix for created networks
dns_suffix string ".internal" DNS suffix for service discovery

How It Works

When network isolation is enabled, each application gets its own Docker network:

[network_isolation]
enabled = true
network_prefix = "gordon"

[routes]
"app.mydomain.com" = "myapp:latest"
"api.mydomain.com" = "myapi:latest"

Creates two isolated networks:

  • gordon-app-mydomain-com
  • gordon-api-mydomain-com

Network Naming

Networks are named: {prefix}-{domain-with-dashes}

Domain Network Name
app.mydomain.com gordon-app-mydomain-com
api.company.io gordon-api-company-io
staging.app.dev gordon-staging-app-dev

Security Benefits

Without Network Isolation

All containers can potentially communicate:

┌──────────────────────────────────────────────┐
│ Default Bridge Network                        │
│                                              │
│  App A ←──────→ App B ←──────→ App C        │
│    ↕              ↕              ↕           │
│  DB A ←──────→ DB B ←──────→ DB C           │
│                                              │
└──────────────────────────────────────────────┘

With Network Isolation

Each app is isolated with its dependencies:

┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐
│ gordon-app-a    │  │ gordon-app-b    │  │ gordon-app-c    │
│                 │  │                 │  │                 │
│  App A ←→ DB A │  │  App B ←→ DB B │  │  App C ←→ DB C │
│                 │  │                 │  │                 │
└─────────────────┘  └─────────────────┘  └─────────────────┘
        ↑                   ↑                   ↑
        └───────── No direct communication ─────┘

Service Discovery

Within an isolated network, services are discoverable by name:

[network_isolation]
enabled = true

[attachments]
"app.mydomain.com" = ["postgres:latest", "redis:latest"]

Your application connects using simple hostnames:

# These work within the isolated network
db = connect("postgresql://postgres:5432/mydb")
cache = connect("redis://redis:6379")

DNS Resolution

The dns_suffix option adds a suffix for internal DNS resolution:

[network_isolation]
dns_suffix = ".internal"

Services can be accessed as:

  • postgres (short form)
  • postgres.internal (with suffix)

Examples

Basic Isolation

[network_isolation]
enabled = true

[routes]
"app.mydomain.com" = "myapp:latest"
"api.mydomain.com" = "myapi:latest"

[attachments]
"app.mydomain.com" = ["app-postgres:latest"]
"api.mydomain.com" = ["api-postgres:latest"]

Each app gets its own network with its own database.

Production Configuration

[network_isolation]
enabled = true
network_prefix = "prod"
dns_suffix = ".internal"

[routes]
"app.company.com" = "company-app:v2.1.0"
"api.company.com" = "company-api:v1.5.0"
"admin.company.com" = "admin-panel:v1.0.0"

Creates networks:

  • prod-app-company-com
  • prod-api-company-com
  • prod-admin-company-com

Shared Services with Network Groups

When apps need to communicate, use network groups:

[network_isolation]
enabled = true

[network_groups]
"backend" = ["app.mydomain.com", "api.mydomain.com"]

[attachments]
"backend" = ["shared-postgres:latest", "shared-redis:latest"]

Both apps share the gordon-backend network.

Inspecting Networks

View created networks:

docker network ls | grep gordon
# gordon-app-mydomain-com
# gordon-api-mydomain-com
# gordon-backend

Inspect a network:

docker network inspect gordon-app-mydomain-com
source
1# Network Isolation
2
3Isolate applications in separate Docker networks for enhanced security.
4
5## Configuration
6
7```toml
8[network_isolation]
9enabled = true
10network_prefix = "gordon"
11dns_suffix = ".internal"
12```
13
14## Options
15
16| Option | Type | Default | Description |
17|--------|------|---------|-------------|
18| `enabled` | bool | `false` | Enable per-app network isolation |
19| `network_prefix` | string | `"gordon"` | Prefix for created networks |
20| `dns_suffix` | string | `".internal"` | DNS suffix for service discovery |
21
22## How It Works
23
24When network isolation is enabled, each application gets its own Docker network:
25
26```
27[network_isolation]
28enabled = true
29network_prefix = "gordon"
30
31[routes]
32"app.mydomain.com" = "myapp:latest"
33"api.mydomain.com" = "myapi:latest"
34```
35
36Creates two isolated networks:
37- `gordon-app-mydomain-com`
38- `gordon-api-mydomain-com`
39
40## Network Naming
41
42Networks are named: `{prefix}-{domain-with-dashes}`
43
44| Domain | Network Name |
45|--------|--------------|
46| `app.mydomain.com` | `gordon-app-mydomain-com` |
47| `api.company.io` | `gordon-api-company-io` |
48| `staging.app.dev` | `gordon-staging-app-dev` |
49
50## Security Benefits
51
52### Without Network Isolation
53
54All containers can potentially communicate:
55
56```
57┌──────────────────────────────────────────────┐
58│ Default Bridge Network                        │
59│                                              │
60│  App A ←──────→ App B ←──────→ App C        │
61│    ↕              ↕              ↕           │
62│  DB A ←──────→ DB B ←──────→ DB C           │
63│                                              │
64└──────────────────────────────────────────────┘
65```
66
67### With Network Isolation
68
69Each app is isolated with its dependencies:
70
71```
72┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐
73│ gordon-app-a    │  │ gordon-app-b    │  │ gordon-app-c    │
74│                 │  │                 │  │                 │
75│  App A ←→ DB A │  │  App B ←→ DB B │  │  App C ←→ DB C │
76│                 │  │                 │  │                 │
77└─────────────────┘  └─────────────────┘  └─────────────────┘
78        ↑                   ↑                   ↑
79        └───────── No direct communication ─────┘
80```
81
82## Service Discovery
83
84Within an isolated network, services are discoverable by name:
85
86```toml
87[network_isolation]
88enabled = true
89
90[attachments]
91"app.mydomain.com" = ["postgres:latest", "redis:latest"]
92```
93
94Your application connects using simple hostnames:
95
96```python
97# These work within the isolated network
98db = connect("postgresql://postgres:5432/mydb")
99cache = connect("redis://redis:6379")
100```
101
102## DNS Resolution
103
104The `dns_suffix` option adds a suffix for internal DNS resolution:
105
106```toml
107[network_isolation]
108dns_suffix = ".internal"
109```
110
111Services can be accessed as:
112- `postgres` (short form)
113- `postgres.internal` (with suffix)
114
115## Examples
116
117### Basic Isolation
118
119```toml
120[network_isolation]
121enabled = true
122
123[routes]
124"app.mydomain.com" = "myapp:latest"
125"api.mydomain.com" = "myapi:latest"
126
127[attachments]
128"app.mydomain.com" = ["app-postgres:latest"]
129"api.mydomain.com" = ["api-postgres:latest"]
130```
131
132Each app gets its own network with its own database.
133
134### Production Configuration
135
136```toml
137[network_isolation]
138enabled = true
139network_prefix = "prod"
140dns_suffix = ".internal"
141
142[routes]
143"app.company.com" = "company-app:v2.1.0"
144"api.company.com" = "company-api:v1.5.0"
145"admin.company.com" = "admin-panel:v1.0.0"
146```
147
148Creates networks:
149- `prod-app-company-com`
150- `prod-api-company-com`
151- `prod-admin-company-com`
152
153### Shared Services with Network Groups
154
155When apps need to communicate, use network groups:
156
157```toml
158[network_isolation]
159enabled = true
160
161[network_groups]
162"backend" = ["app.mydomain.com", "api.mydomain.com"]
163
164[attachments]
165"backend" = ["shared-postgres:latest", "shared-redis:latest"]
166```
167
168Both apps share the `gordon-backend` network.
169
170## Inspecting Networks
171
172View created networks:
173
174```bash
175docker network ls | grep gordon
176# gordon-app-mydomain-com
177# gordon-api-mydomain-com
178# gordon-backend
179```
180
181Inspect a network:
182
183```bash
184docker network inspect gordon-app-mydomain-com
185```
186
187## Related
188
189- [Network Groups](./network-groups.md)
190- [Attachments](./attachments.md)
191- [Configuration Overview](./index.md)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close