Docker Course
Docker
/
Intermediate

GitHub Actions + Docker

Definition

The use of GitHub's native CI/CD platform to automatically build Docker images from a repository's Dockerfile and push them to a registry whenever code is merged.

Explain Like I'm New

A robot that lives in your GitHub repo. You merge a Pull Request, the robot wakes up, runs `docker build`, and uploads the new version of your app to the cloud automatically.

Real World Example

You write a `.github/workflows/docker.yml` file. It tells GitHub: 'Every time a commit hits the main branch, log into AWS ECR, run docker build, tag it with the commit hash, and push it.'

Common Use Cases

  • •Open-source workflows
  • •Automated releases

Interview Questions

basic

  • Can GitHub Actions automatically push a Docker Image to Docker Hub for you?

intermediate

  • How do you securely pass your Docker Hub password to a GitHub Actions workflow?

Flash Cards

Question

Can it push to Docker Hub?

Click to reveal answer
Answer

Yes. GitHub Actions has massive community support and official actions specifically built for logging into and pushing to Docker Hub.

Question

Securely pass password?

Click to reveal answer
Answer

You must never write the password in the YAML file. You store the password in 'GitHub Repository Secrets'. The workflow YAML references the secret securely using syntax like `${{ secrets.DOCKER_PASSWORD }}`.