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
- github-actions-workflow-basics
- github-actions-job-outputs
- 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
serviceskeyword"
- 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.
License: CC-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..
Cite this
iinventedlight. 2026. "Service containers run Docker services beside a job and are torn down when it ends." iinventedlight Library, iil:note:0tzcjjek, version of 2026-11-17. https://iinventedlight.com/library/notes/github-actions-service-containers/. License: CC-BY-4.0.
@misc{iil_note_0tzcjjek,
author = {{iinventedlight}},
title = {{Service containers run Docker services beside a job and are torn down when it ends}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-17},
url = {https://iinventedlight.com/library/notes/github-actions-service-containers/},
note = {Permanent ID iil:note:0tzcjjek. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/github-actions-service-containers.md.