Cloud Computing, DevOps

5 Mins Read

Building and Securing Docker Images with Docker Content Trust

Voiced by Amazon Polly

Introduction

Docker has become an essential tool for packaging, running, and distributing applications. While creating images and pushing them to a registry is common practice, enabling Docker Content Trust (DCT) adds an important layer of security. This blog walks you through building a Docker image, specifically a WordPress setup, configuring the environment, and pushing the image to a registry with Content Trust enabled.

When working with containerized environments, ensuring that the images you build and deploy are verified and secure is critical. Docker Content Trust provides a mechanism for signing and validating the integrity of Docker images before they are pulled or executed.

In this guide, you’ll learn how to:

  • Set up Docker on an Ubuntu VM
  • Build a custom WordPress Docker image
  • Create and run containers for WordPress and MySQL
  • Tag and push these images to a secure registry using Content Trust

This step-by-step approach is suitable for developers, DevOps engineers, and cloud practitioners who want to enhance container security while maintaining a smooth deployment workflow.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Docker Image

A Docker image is a lightweight, executable package that contains everything needed to run an application, code, libraries, dependencies, environment settings, and runtime. It acts as a blueprint for creating Docker containers.

Docker images are:

  • Immutable (once built, they don’t change)
  • Portable across environments
  • Version-controlled using tags
  • Stored in registries like Docker Hub, GCR, or ECR

What Is Docker Content Trust?

Docker Content Trust (DCT) ensures that the images you use are cryptographically signed. This prevents unverified or tampered images from being pulled or run in your environment.

Why Content Trust Matters

  • Ensures authenticity of images
  • Protects against malicious alterations
  • Allows organizations to enforce security policies
  • Provides traceability for image versions

When DCT is enabled, Docker will only interact with images that are signed. Any unsigned or modified image will be rejected.

Step-by-Step Guide

Step 1: Create a VM with Ubuntu and SSH into it

Update VM

Let apt access a repository over HTTPS

Add Docker’s GPG key

step1

Add the Docker’s repository

step1b

Update Docker’s repository

Install docker

Add the user to the Docker

step1c

Note: Exit and SSH again

Step 2: Curl wordpress into local

step2

Install unzip

Unzip latest.zip

step2b

step2c

step2d

Create a Dockerfile and paste the content

step2e

Step 3: Build the Docker file

step3

Create container out of image and create variable

step3b

Pass the docker-wordpress-local to port 8080, create a network, and attack both WordPress and MySQL

step3c

Check volume created

step3d

Inspect volume for mount point

step3e

Check the content of the volume

step3f

Check the running container

step3g

Step 4: Copy and paste the VM IP on port 8080 and enter the information directly, as we have entered the variables above

step4

Copy the JSON keyfile from the service account, check with all the permissions

Paste the content of the file downloaded and save it.

step4b

Step 5: Login with the service account

step5

step5b

step5c

step5d

step5e

Refer for authentication to push: https://cloud.google.com/container-registry/docs/advanced-authentication

Conclusion

Securing your container workflow is just as important as building and running your applications. By integrating Docker Content Trust into your image-building pipeline, you ensure that every image pushed, pulled, or deployed is verified and trustworthy.

From setting up Docker, building custom WordPress images, configuring environments, and pushing images to a secure registry, you now have a complete understanding of how to maintain both functionality and security throughout your container lifecycle.

Drop a query if you have any questions regarding Docker Content Trust and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

FAQs

1. Is Docker Content Trust enabled by default?

ANS: – No. DCT must be manually enabled using the environment variable:
export DOCKER_CONTENT_TRUST=1.

2. Do all registries support Content Trust?

ANS: – Docker Hub supports DCT, but platforms like Google Container Registry (GCR) or AWS ECR may require additional steps or alternative signing mechanisms.

3. Can I push unsigned images when DCT is enabled?

ANS: – No. When Content Trust is enabled, Docker will block pushes and pulls of unsigned images unless the variable is turned off.

WRITTEN BY Swapnil Kumbar

Swapnil Kumbar is a Senior Research Associate at CloudThat with over 2.5 years of experience in DevOps. He specializes in AWS, Kubernetes, automation, and cloud-native technologies. Passionate about innovation and research, Swapnil focuses on building scalable infrastructure, optimizing deployments, and exploring emerging tools. In his free time, he actively contributes to knowledge sharing and community learning initiatives.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!