---
type: resource-type
title: Service
description: A containerized service definition in Docker Compose
name: Service
lexicon: docker
resource_type: Docker::Compose::Service
---
A containerized service definition in Docker Compose

## Properties

- `image` (`string`): Container image to use
- `build` (`object`): Build configuration
- `command` (`string | string[]`): Override the default command
- `entrypoint` (`string | string[]`): Override the default entrypoint
- `environment` (`Record<string, string>`): Environment variables
- `ports` (`string[]`): Published ports
- `volumes` (`string[]`): Volume mounts
- `networks` (`string[]`): Networks to attach
- `depends_on` (`string[] | Record<string, { condition: "service_started" | "service_healthy" | "service_completed_successfully"; restart?: boolean; required?: boolean }>`): Service dependencies (short list-form, or long form with a wait condition)
- `restart` (`string`): Restart policy
- `labels` (`Record<string, string>`): Container labels
- `healthcheck` (`object`): Health check configuration
- `deploy` (`object`): Swarm deployment configuration
- `secrets` (`string[]`): Secrets to expose
- `configs` (`string[]`): Configs to expose

## Governed by

- [DKRD001](/rules/DKRD001.md): Service uses :latest or untagged image — specify an explicit version tag
- [DKRD003](/rules/DKRD003.md): Service exposes SSH port (22) externally — this is a security risk
- [DKRS001](/rules/DKRS001.md): No Latest Tag
