My Tech Blog

CI/CD with Containers – A Modern Workflow

By Alex Rivera • September 18, 2025 • Comments

Continuous Integration and Continuous Delivery (CI/CD) have become the backbone of modern software development. When combined with containerization, they unlock unparalleled speed, consistency, and scalability. In this post we’ll explore how to set up a full CI/CD pipeline using Docker, GitHub Actions, and Kubernetes.

CI/CD pipeline diagram

Why Containers?

Containers encapsulate an application with all its dependencies, ensuring that the code you test locally runs exactly the same in staging and production. This eliminates “works on my machine” bugs and speeds up onboarding.

Step‑by‑Step Pipeline

  1. Source Code – Push to a Git repository.
  2. Build – GitHub Actions builds a Docker image.
  3. Test – Run unit, integration, and security scans inside the container.
  4. Publish – Push the image to a container registry.
  5. Deploy – Use Kubernetes manifests to roll out the new version.

GitHub Actions Workflow

name: CI/CD Pipeline
on:
  push:
    branches: [ main ]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Login to Docker Hub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USER }}
          password: ${{ secrets.DOCKER_PASS }}

      - name: Build and push image
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          tags: ${{ secrets.DOCKER_USER }}/cicd-demo:latest

      - name: Deploy to Kubernetes
        uses: azure/k8s-deploy@v4
        with:
          namespace: production
          manifests: |
            k8s/deployment.yaml
            k8s/service.yaml
          images: |
            ${{ secrets.DOCKER_USER }}/cicd-demo:latest
          kubectl-version: 'v1.28.0'

Best Practices

Conclusion

By marrying CI/CD with containers, you gain a repeatable, portable, and fast delivery mechanism. The example above shows a minimal yet powerful pipeline that can be extended with advanced testing, monitoring, and rollback strategies.

Comments

Share your thoughts below! (Feature coming soon.)