Docker and GitHub Actions are a common pairing in a modern DevOps stack. Here is how they fit together and a practical way to wire them up.
Where Docker fits
Docker builds, ships and runs applications inside containers - isolated processes that bundle the code, runtime and libraries so 'works on my machine' stops being a problem.
# syntax=docker/dockerfile:1
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine AS run
WORKDIR /app
ENV NODE_ENV=production
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]Where GitHub Actions fits
GitHub Actions runs event-driven workflows (on push, PR, schedule, etc.) defined as YAML in .github/workflows, using reusable 'actions' from the marketplace or your own repos.
name: ci
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix: { node: [18, 20, 22] }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: ${{ matrix.node }}, cache: npm }
- run: npm ci
- run: npm testMaking them work together
- Pin base image tags (or digests) instead of :latest for reproducibility
- Order layers from least- to most-frequently changed to maximize cache hits
- Pin actions to a commit SHA and review third-party actions before use
- Use OIDC for cloud auth and set minimal permissions blocks
Want this pairing set up properly, with docs and handover? That is exactly the kind of work CodeWizard's embedded senior engineers do - and both Docker and GitHub Actions have active community groups you can join for free.