Kahibaro
Discord Login Register

Introduction to Docker and container images

Docker as a Container Engine

Docker is one of the most widely used tools for building, running, and distributing containers. While OpenShift and modern Kubernetes-based platforms often use other runtimes under the hood (like crio or containerd), Docker is still useful as a teaching tool to understand:

At a high level, Docker provides:

You’ll later see how these same concepts appear in OpenShift using different tools and commands, but the ideas remain very similar.

What Is a Container Image?

A container image is:

A container at runtime is essentially:

The image itself is immutable; any changes a running container makes (logs, temporary files, etc.) go into a separate, writable layer on top of the image.

Image Layers

Docker images are layered. Each instruction in a Dockerfile typically creates a new layer. Layers are:

Layering enables:

Conceptually, an image might look like:

Each layer is read-only, and at runtime Docker adds a writable layer on top to create the container’s root filesystem.

Docker Image Naming and Tagging

Images are referenced using a structured name:

Examples:

Components:

Tags are important for:

Basic Docker CLI Workflow (Conceptual)

Even if you don’t run Docker directly in OpenShift, understanding the Docker-style workflow helps you understand image lifecycles.

Typical lifecycle:

  1. Build an image from a Dockerfile:
   docker build -t myapp:1.0 .
  1. Run a container from the image:
   docker run --name myapp-container -p 8080:8080 myapp:1.0
  1. Tag the image for a registry:
   docker tag myapp:1.0 registry.example.com/myteam/myapp:1.0
  1. Push the image to a registry:
   docker push registry.example.com/myteam/myapp:1.0

OpenShift will later perform similar operations:

Dockerfile Basics

A Dockerfile is a text file that describes how to build an image. Docker reads it and executes each instruction in order, creating layers along the way.

Typical structure:

  1. Choose a base image
  2. Install dependencies and tools
  3. Copy application code
  4. Configure runtime (ports, environment)
  5. Define the container’s default command

Example: a simple Python web app

# 1. Base image
FROM python:3.11-slim
# 2. Set working directory
WORKDIR /app
# 3. Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 4. Copy application code
COPY . .
# 5. Expose port and set default command
EXPOSE 8080
CMD ["python", "app.py"]

Key instructions (conceptually):

Image Size and Optimization Considerations

Even though this chapter is introductory, a few practical points matter early:

These choices affect:

Relationship Between Docker Images and OpenShift

OpenShift does not require the Docker daemon, but it fully understands Docker/OCI-compatible images:

In other words:

Summary: What You Should Take Away

From this chapter you should be able to:

Views: 12

Comments

Please login to add a comment.

Don't have an account? Register now!