Search code examples
dockergithub-actions

How can I use private docker image in github actions


I'm trying to set up a job in github-actions that runs a private docker image. I will do the build inside that docker image using the container option. link.

I'm using the following code:

jobs:
  container1:
    runs-on: ubuntu-latest
    container: saeed/privateimage:1
    steps:
      - uses: actions/checkout@v2
      - run: |
          echo "Runs inside a container"

But I can't provide my docker hub creds so it fails.

How can I authenticate to pull that private image?

Thanks.


Solution

  • It looks like support for this has been added just today, see blog post.

    The post uses this example:

    jobs:
      build:
        container:
          image: octocat/ci-image:latest
          credentials:
            username: mona
            password: ${{ secrets.docker_hub_password }}
        services:
          db:
            image:  octocat/testdb:latest
            credentials:
              username: mona
              password: ${{ secrets.docker_hub_password }}
    

    The documentation for container is here.