---
source: https://iinventedlight.com/library/notes/github-actions-service-containers.md
title: "Service containers run Docker services beside a job and are torn down when it ends"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (GitHub Docs); CC-BY-4.0 (github/docs (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: GitHub Docs, Communicating with Docker service containers, CC-BY-4.0 (https://raw.githubusercontent.com/github/docs/main/LICENSE). Copyright GitHub, Inc.; github/docs (GitHub), Workflow syntax: jobs.<job_id>.services, CC-BY-4.0 (https://raw.githubusercontent.com/github/docs/main/LICENSE). Copyright GitHub, Inc.."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-17
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-17
as_of: 2026-11-17
confidence: medium
untested: "Not reproduced (2026-11-17). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: GitHub Actions service containers"
tags: [github-actions, service-containers, docker, services]
client: Librarian
sources:
  - id: S1
    title: "Communicating with Docker service containers"
    publisher: GitHub Docs
    url: https://docs.github.com/en/actions/tutorials/use-containerized-services/use-docker-service-containers
    accessed: 2026-11-17
    license: "CC-BY-4.0"
  - id: S2
    title: "Workflow syntax: jobs.<job_id>.services"
    publisher: github/docs (GitHub)
    url: https://github.com/github/docs/blob/main/content/actions/reference/workflows-and-actions/workflow-syntax.md
    accessed: 2026-11-17
    license: "CC-BY-4.0"
---
# Service containers run Docker services beside a job and are torn down when it ends
**Answer:** Service containers are Docker containers that host services a workflow may need, such as a database or a memory cache. You configure them with the `services` keyword on a job. GitHub creates a fresh container for each service and destroys it when the job completes. You cannot create and use service containers inside a composite action.

## How a job reaches the service

If the job itself runs in a container, you access the service by the label you configure. That label becomes the hostname, and you do not need to map ports. If the job runs directly on the runner machine, access the service at `localhost` plus a mapped port, and you must map ports with the `ports` keyword.

The runner creates a Docker network on its own and manages each service container's life cycle. The Docker image to use as the service container is set with `image`. Map host and container ports in the form `8080:80`.

## See also

- [docker-compose-basics](https://iinventedlight.com/library/notes/docker-compose-basics/)
- [github-actions-workflow-basics](https://iinventedlight.com/library/notes/github-actions-workflow-basics/)
- [github-actions-job-outputs](https://iinventedlight.com/library/notes/github-actions-job-outputs/)
- [github-actions-token-permissions](https://iinventedlight.com/library/notes/github-actions-token-permissions/)

## Claims

- id: C1
  claim: Configure service containers with the services keyword on a job.
  source: S1
  evidence: "You can use the `services` keyword"

- id: C2
  claim: Service containers cannot be created inside a composite action.
  source: S1
  evidence: "you cannot create and use service containers inside a composite action"

- id: C3
  claim: jobs.services hosts service containers for a workflow job.
  source: S2
  evidence: "Used to host service containers for a job in a workflow"

- id: C4
  claim: The runner creates a Docker network and manages each service container's life cycle.
  source: S2
  evidence: "The runner automatically creates a Docker network"

## Sources

- [S1] Communicating with Docker service containers. GitHub Docs. https://docs.github.com/en/actions/tutorials/use-containerized-services/use-docker-service-containers . License: CC-BY-4.0. Accessed 2026-11-17.

- [S2] Workflow syntax: jobs.<job_id>.services. github/docs (GitHub). https://github.com/github/docs/blob/main/content/actions/reference/workflows-and-actions/workflow-syntax.md . License: CC-BY-4.0. Accessed 2026-11-17.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: GitHub Docs, Communicating with Docker service containers, CC-BY-4.0 (https://raw.githubusercontent.com/github/docs/main/LICENSE). Copyright GitHub, Inc.; github/docs (GitHub), Workflow syntax: jobs.<job_id>.services, CC-BY-4.0 (https://raw.githubusercontent.com/github/docs/main/LICENSE). Copyright GitHub, Inc.. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
