Skip to content

Commit d9e59a0

Browse files
authored
docker envs (#212)
1 parent 0db2edc commit d9e59a0

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

apps/docs/content/docker/overview.mdx

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Docker Service
3-
desc:
3+
desc: Comprehensive guide to using Docker on Zerops with VM-based environments. Includes configuration examples and best practices.
44
---
55

66
import UnorderedCodeList from '@site/src/components/UnorderedCodeList';
@@ -91,6 +91,52 @@ For projects using Docker Compose, additional configuration is required:
9191
network_mode: host
9292
```
9393

94+
3. **Start Command**:
95+
```yaml title="zerops.yml"
96+
run:
97+
start: docker compose up --force-recreate
98+
```
99+
100+
### Environment Variables
101+
102+
When using Docker services, there's an additional layer to consider since environment variables defined in Zerops must be explicitly passed to your Docker containers.
103+
104+
#### 1. Defining Variables in Zerops
105+
106+
Define your environment variables in the `run.envVariables` section of your `zerops.yml` (example uses [referenced](/features/env-variables#referencing-variables) variables):
107+
108+
```yaml title="zerops.yml"
109+
zerops:
110+
- setup: app
111+
run:
112+
envVariables:
113+
DB_HOST: ${db_hostname}
114+
DB_PORT: ${db_port}
115+
```
116+
117+
#### 2. Passing Variables to Docker Containers
118+
119+
For single containers, pass variables using the `-e` flag:
120+
121+
```yaml title="zerops.yml"
122+
run:
123+
prepareCommands:
124+
- docker image pull my-application:latest
125+
start: docker run -e DB_HOST -e DB_PORT --network=host my-application:latest
126+
```
127+
128+
For Docker Compose setups, pass environment variables in your `docker-compose.yml`:
129+
130+
```yaml title="docker-compose.yml"
131+
services:
132+
api:
133+
image: my-application:latest
134+
network_mode: host
135+
environment:
136+
- DB_HOST
137+
- DB_PORT
138+
```
139+
94140
## Implementation Examples
95141

96142
### Single Container
@@ -187,4 +233,4 @@ Docker services on Zerops have specific scaling characteristics that differ from
187233
- Still supports multiple containers through `minContainers` and `maxContainers`
188234
- Consider breaking large services into smaller components
189235
- Implement proper health checks for reliable scaling
190-
- Use horizontal scaling when possible to avoid VM restarts
236+
- Use horizontal scaling when possible to avoid VM restarts

0 commit comments

Comments
 (0)