A container image is an immutable, bootable snapshot of a server or microservice. It packages the application code, dependencies, assets, and other resources needed to instantiate a container. section 3.4
Use an image as the deployable artifact in this workflow:
- Create a Dockerfile describing the application, dependencies, base image, and supporting assets. section 3.8.1
- Build the image with docker build, assigning a useful name and version tag. section 3.12 section 6.8.1
- Run the image as a container to test the packaged microservice. section 3.6
- Tag the image with the container registry address, log in, and push it for deployment. section 6.11.2
- Point Kubernetes deployment configuration at the published image and verify the resulting pods, deployment, and service. section 7.12
Build and publish a versioned image
For a video-streaming microservice, build version 1, tag it for the target registry, authenticate, and push it: docker build -t video-streaming:1 --file Dockerfile-prod .; docker tag video-streaming:1 <registry-url>/video-streaming:1; docker login <registry-url>; docker push <registry-url>/video-streaming:1. Increment the version tag for later deployments. section 6.11.2
Listing 3.1 A Dockerfile for our video-streaming microservice
FROM node:18.17.1 #1 WORKDIR /usr/src/app #2 COPY package*.json ./ #3 RUN npm ci --omit=dev #4 COPY ./src ./src #5 COPY ./videos ./videos #6 CMD npm start #7
Inspect a complete Dockerfile that derives from node:18.17.1, installs production dependencies, copies application assets, and defines the startup command. section 3.8.1
Immutability makes a built image a stable artifact: tests and security checks remain valid because the image cannot be modified. A running container may change its filesystem, but those changes do not alter the source image. section 3.4
























