Service
Optionen eines Compose-Services. Diese Blöcke gehören in einen Service-Klammerblock.
| Block | Art | Platz |
|---|---|---|
| Image … | Stapel | in einen "Service"-Block |
| Build Ordner … Dockerfile … | Stapel | in einen "Service"-Block |
| Build-Arg … = … | Stapel | in einen "Service"-Block |
| Port Host … → Container … … | Stapel | in einen "Service"-Block |
| nur intern freigeben Port … | Stapel | in einen "Service"-Block |
| Variable … = … | Stapel | in einen "Service"-Block |
| Variablen aus Datei … | Stapel | in einen "Service"-Block |
| Volume … → … nur lesen … | Stapel | in einen "Service"-Block |
| wartet auf … bis … | Stapel | in einen "Service"-Block |
| Neustart … | Stapel | in einen "Service"-Block |
| Command … | Stapel | in einen "Service"-Block |
| Entrypoint … | Stapel | in einen "Service"-Block |
| im Netzwerk … | Stapel | in einen "Service"-Block |
| Healthcheck … alle … Timeout … Versuche … | Stapel | in einen "Service"-Block |
| Label … = … | Stapel | in einen "Service"-Block |
| Limit CPU … RAM … | Stapel | in einen "Service"-Block |
| Replicas … | Stapel | in einen "Service"-Block |
| Option … = … | Stapel | in einen "Service"-Block |
| schalte … ein | Stapel | in einen "Service"-Block |
| Host … zeigt auf … | Stapel | in einen "Service"-Block |
| nutzt Secret … | Stapel | in einen "Service"-Block |
| Logging … max. Größe … Dateien … | Stapel | in einen "Service"-Block |
| nur im Profil … | Stapel | in einen "Service"-Block |
Image …
Stapelblock · Typ-ID svc_image · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | IMAGE | Text | nginx:latest |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
Build Ordner … Dockerfile …
Stapelblock · Typ-ID svc_build · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | CTX | Text | . | |
| 2 | FILE | Text | Dockerfile |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
build: .
Build-Arg … = …
Stapelblock · Typ-ID svc_build_arg · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | K | Text | NODE_ENV | |
| 2 | V | Text | production |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
build:
context: .
args:
NODE_ENV: production
Port Host … → Container … …
Stapelblock · Typ-ID svc_port · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | HOST | Text | 8080 | |
| 2 | CONT | Text | 80 | |
| 3 | PROTO | Auswahl | tcp | tcp, udp |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
ports:
- "8080:80"
nur intern freigeben Port …
Stapelblock · Typ-ID svc_expose · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | PORT | Text | 3000 |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
expose:
- "3000"
Variable … = …
Stapelblock · Typ-ID svc_env · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | K | Text | APP_ENV | |
| 2 | V | Text | production |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
environment:
APP_ENV: production
Variablen aus Datei …
Stapelblock · Typ-ID svc_env_file · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | FILE | Text | .env |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
env_file:
- .env
Volume … → … nur lesen …
Stapelblock · Typ-ID svc_volume · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | SRC | Text | data | |
| 2 | DST | Text | /var/lib/data | |
| 3 | RO | Häkchen | aus |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
volumes:
- data:/var/lib/data
wartet auf … bis …
Stapelblock · Typ-ID svc_depends · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | NAME | Text | db | |
| 2 | COND | Auswahl | gestartet | gestartet → service_started, gesund → service_healthy, fertig → service_completed_successfully |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
depends_on:
db:
condition: service_started
Neustart …
Stapelblock · Typ-ID svc_restart · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | R | Auswahl | unless-stopped | unless-stopped, always, on-failure, no |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
restart: unless-stopped
Command …
Stapelblock · Typ-ID svc_command · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | CMD | Text | npm start |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
command:
- npm
- start
Entrypoint …
Stapelblock · Typ-ID svc_entrypoint · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | CMD | Text | /docker-entrypoint.sh |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
entrypoint:
- /docker-entrypoint.sh
im Netzwerk …
Stapelblock · Typ-ID svc_network · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | NAME | Text | backend |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
networks:
- backend
Healthcheck … alle … Timeout … Versuche …
Stapelblock · Typ-ID svc_healthcheck · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | CMD | Text | `curl -f http://localhost/ | |
| 2 | INT | Text | 30s | |
| 3 | TO | Text | 5s | |
| 4 | RET | Zahl | 3 |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
healthcheck:
test:
- CMD-SHELL
- curl -f http://localhost/ || exit 1
interval: 30s
timeout: 5s
retries: 3
Label … = …
Stapelblock · Typ-ID svc_label · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | K | Text | com.example.team | |
| 2 | V | Text | platform |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
labels:
com.example.team: platform
Limit CPU … RAM …
Stapelblock · Typ-ID svc_resources · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | CPU | Text | 0.5 | |
| 2 | MEM | Text | 512M |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
Replicas …
Stapelblock · Typ-ID svc_replicas · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | N | Zahl | 2 |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
deploy:
replicas: 2
Option … = …
Stapelblock · Typ-ID svc_option · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | K | Auswahl | container_name | container_name, hostname, user, working_dir, platform, pull_policy, stop_signal, stop_grace_period, shm_size, network_mode, domainname |
| 2 | V | Text | my-app |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
container_name: my-app
schalte … ein
Stapelblock · Typ-ID svc_flag · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | K | Auswahl | privileged | privileged, tty, stdin_open, init, read_only |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
privileged: true
Host … zeigt auf …
Stapelblock · Typ-ID svc_extra_host · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | H | Text | host.docker.internal | |
| 2 | IP | Text | host-gateway |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
extra_hosts:
- host.docker.internal:host-gateway
nutzt Secret …
Stapelblock · Typ-ID svc_secret · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | NAME | Text | db_password |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
secrets:
- db_password
Logging … max. Größe … Dateien …
Stapelblock · Typ-ID svc_logging · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | DRV | Auswahl | json-file | json-file, local, syslog, journald, none |
| 2 | SIZE | Text | 10m | |
| 3 | FILES | Zahl | 3 |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"
nur im Profil …
Stapelblock · Typ-ID svc_profile · gehört in einen "Service"-Block
| # | Feld | Art | Standard | Auswahl |
|---|---|---|---|---|
| 1 | P | Text | debug |
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
profiles:
- debug