Docker Builds in GitHub#

GitHub will build Docker containers for you. The resulting built container is available on GitHub’s public repository, which greatly simplifies deployments. Building using GitHub is convenient but also makes your container images public, so be careful to not include any secrets in them.

Enable Actions for a Repository#

Actions are enabled when you place YAML files in the .github/workflows directory in the repository. Follow the instructions in GitHub’s Publishing images to GitHub Packages documentation.


The example action in the documentation only builds when you push to the release branch. You should change the on declaration to:

    types: [published]
    branches: ['main']
  workflow_dispatch: {}

Watch and Run#

After you push your workflow file go to GitHub and watch the action. Make sure it completes successfully. Once it does you will be able to use the image that was built:

$ docker pull
$ docker run -it --rm -p 8000:8000