Zum Hauptinhalt springen

Service

Optionen eines Compose-Services. Diese Blöcke gehören in einen Service-Klammerblock.

BlockArtPlatz
Image …Stapelin einen "Service"-Block
Build Ordner … Dockerfile …Stapelin einen "Service"-Block
Build-Arg … = …Stapelin einen "Service"-Block
Port Host … → Container … …Stapelin einen "Service"-Block
nur intern freigeben Port …Stapelin einen "Service"-Block
Variable … = …Stapelin einen "Service"-Block
Variablen aus Datei …Stapelin einen "Service"-Block
Volume … → … nur lesen …Stapelin einen "Service"-Block
wartet auf … bis …Stapelin einen "Service"-Block
Neustart …Stapelin einen "Service"-Block
Command …Stapelin einen "Service"-Block
Entrypoint …Stapelin einen "Service"-Block
im Netzwerk …Stapelin einen "Service"-Block
Healthcheck … alle … Timeout … Versuche …Stapelin einen "Service"-Block
Label … = …Stapelin einen "Service"-Block
Limit CPU … RAM …Stapelin einen "Service"-Block
Replicas …Stapelin einen "Service"-Block
Option … = …Stapelin einen "Service"-Block
schalte … einStapelin einen "Service"-Block
Host … zeigt auf …Stapelin einen "Service"-Block
nutzt Secret …Stapelin einen "Service"-Block
Logging … max. Größe … Dateien …Stapelin einen "Service"-Block
nur im Profil …Stapelin einen "Service"-Block

Image …​

Image [1]

Stapelblock · Typ-ID svc_image · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1IMAGETextnginx:latest
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest

Build Ordner … Dockerfile …​

Build Ordner [1] Dockerfile [2]

Stapelblock · Typ-ID svc_build · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1CTXText.
2FILETextDockerfile
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
build: .

Build-Arg … = …​

Build-Arg [1] = [2]

Stapelblock · Typ-ID svc_build_arg · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1KTextNODE_ENV
2VTextproduction
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
build:
context: .
args:
NODE_ENV: production

Port Host … → Container … …​

Port Host [1] → Container [2] [3]

Stapelblock · Typ-ID svc_port · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1HOSTText8080
2CONTText80
3PROTOAuswahltcptcp, udp
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
ports:
- "8080:80"

nur intern freigeben Port …​

nur intern freigeben Port [1]

Stapelblock · Typ-ID svc_expose · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1PORTText3000
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
expose:
- "3000"

Variable … = …​

Variable [1] = [2]

Stapelblock · Typ-ID svc_env · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1KTextAPP_ENV
2VTextproduction
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
environment:
APP_ENV: production

Variablen aus Datei …​

Variablen aus Datei [1]

Stapelblock · Typ-ID svc_env_file · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1FILEText.env
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
env_file:
- .env

Volume … → … nur lesen …​

Volume [1] → [2] nur lesen [3]

Stapelblock · Typ-ID svc_volume · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1SRCTextdata
2DSTText/var/lib/data
3ROHäkchenaus
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
volumes:
- data:/var/lib/data

wartet auf … bis …​

wartet auf [1] bis [2]

Stapelblock · Typ-ID svc_depends · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1NAMETextdb
2CONDAuswahlgestartetgestartet → 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 …​

Neustart [1]

Stapelblock · Typ-ID svc_restart · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1RAuswahlunless-stoppedunless-stopped, always, on-failure, no
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
restart: unless-stopped

Command …​

Command [1]

Stapelblock · Typ-ID svc_command · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1CMDTextnpm start
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
command:
- npm
- start

Entrypoint …​

Entrypoint [1]

Stapelblock · Typ-ID svc_entrypoint · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1CMDText/docker-entrypoint.sh
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
entrypoint:
- /docker-entrypoint.sh

im Netzwerk …​

im Netzwerk [1]

Stapelblock · Typ-ID svc_network · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1NAMETextbackend
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
networks:
- backend

Healthcheck … alle … Timeout … Versuche …​

Healthcheck [1] alle [2] Timeout [3] Versuche [4]

Stapelblock · Typ-ID svc_healthcheck · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1CMDText`curl -f http://localhost/
2INTText30s
3TOText5s
4RETZahl3
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 … = …​

Label [1] = [2]

Stapelblock · Typ-ID svc_label · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1KTextcom.example.team
2VTextplatform
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
labels:
com.example.team: platform

Limit CPU … RAM …​

Limit CPU [1] RAM [2]

Stapelblock · Typ-ID svc_resources · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1CPUText0.5
2MEMText512M
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M

Replicas …​

Replicas [1]

Stapelblock · Typ-ID svc_replicas · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1NZahl2
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
deploy:
replicas: 2

Option … = …​

Option [1] = [2]

Stapelblock · Typ-ID svc_option · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1KAuswahlcontainer_namecontainer_name, hostname, user, working_dir, platform, pull_policy, stop_signal, stop_grace_period, shm_size, network_mode, domainname
2VTextmy-app
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
container_name: my-app

schalte … ein​

schalte [1] ein

Stapelblock · Typ-ID svc_flag · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1KAuswahlprivilegedprivileged, tty, stdin_open, init, read_only
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
privileged: true

Host … zeigt auf …​

Host [1] zeigt auf [2]

Stapelblock · Typ-ID svc_extra_host · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1HTexthost.docker.internal
2IPTexthost-gateway
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
extra_hosts:
- host.docker.internal:host-gateway

nutzt Secret …​

nutzt Secret [1]

Stapelblock · Typ-ID svc_secret · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1NAMETextdb_password
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
secrets:
- db_password

Logging … max. Größe … Dateien …​

Logging [1] max. Größe [2] Dateien [3]

Stapelblock · Typ-ID svc_logging · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1DRVAuswahljson-filejson-file, local, syslog, journald, none
2SIZEText10m
3FILESZahl3
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
logging:
driver: json-file
options:
max-size: 10m
max-file: "3"

nur im Profil …​

nur im Profil [1]

Stapelblock · Typ-ID svc_profile · gehört in einen "Service"-Block

#FeldArtStandardAuswahl
1PTextdebug
Erzeugtes YAML mit Standardwerten
services:
web:
image: nginx:latest
profiles:
- debug