Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 3

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:

jobs:
  build:

    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:12.1
        env:
          POSTGRES_USER: postgres
          POSTGRES_DB: postgres

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

/usr/bin/docker version --format '{{.Server.APIVersion}}'
'1.40'
Docker daemon API version: '1.40'
/usr/bin/docker version --format '{{.Client.APIVersion}}'
'1.40'
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
14c8b34467509a9e2e07d8ea607cf1a5e0e45e4cbcb28d9a270edc5c517ca89a
/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
docker.io/library/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?

2 Replies
Highlighted
GitHub Partner
Message 2 of 3

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

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: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-...

Highlighted
Copilot Lvl 3
Message 3 of 3

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

Good information.