6.2. Docker Builds on 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.
Watch and Run#
Tip
The GitHub build action is triggered every time you make a release.
Go to your repository on GitHub and select “Actions”. You will see your job running. You can click it to see the logs. If it built for you it’s likely to build on GitHub. But sometimes things go sideways so in the action you can manually trigger a workflow.
Go back to the “Code” page of your repository and select “Packages” on the right. You will see a publicly available built container image! Run your public image by giving Docker the URL that GitHub provides:
$ docker pull ghcr.io/your-name/repo-name:main
$ docker run -it --rm -p 8000:8000 ghcr.io/your-name/repo-name:main