Caching services? e.g. caching a postgres Docker image in a service

I have a postgres server that’s initialised like this in the yaml file:


    runs-on: ubuntu-latest

        image: postgres:12.1
          POSTGRES_USER: postgres
          POSTGRES_DB: postgres

This is (part of) the logs that I get:

/usr/bin/docker version --format '{{.Server.APIVersion}}'
Docker daemon API version: '1.40'
/usr/bin/docker version --format '{{.Client.APIVersion}}'
Docker client API version: '1.40'
/usr/bin/docker ps --all --quiet --no-trunc --filter "label=671ee6"
/usr/bin/docker network prune --force --filter "label=671ee6"
/usr/bin/docker network create --label 671ee6 github_network_c2a899fe9e4c41cd84c08a17df2f73bc
/usr/bin/docker pull postgres:12.1
12.1: Pulling from library/posters
8ec398bc0356: Pulling fs layer
6b5ee1c74b9a: Pull complete
5fcc518252b4: Pull complete
Digest: sha256:3657548977d593c9ab6d70d1ffc43ceb3b5164ae07ac0f542d2ea139664eb6b3
Status: Downloaded newer image for postgres:12.1

I’m assuming because it’s downloading docker images, that these images can be cached? (I don’t expect a Docker container to be cached, since it’s running software that’s ephemeral)

Is it possible to cache this, and if so, how?

The Docker image postgres:12.1 you set via jobs.<job_id>.services.image is used as the service container to host service for the job in your workflow.
The service containers are useful for creating databases or cache services, and they will be stopped and removed at the end of the job execution.
More details about service containers, you can reference here:

Good information.