liveBook · Manning

Context directory

As explained in Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more

A context directory is a directory containing the files and build instructions made available to a container image build.

A context directory contains a Containerfile and the other files made available during a container image build. Podman reads source files such as index.html from this directory when executing COPY instructions. section 2.3.2

Use a context directory to organize and automate image builds:

  • Create an application directory, place the Containerfile and application content inside it, then run podman build with that directory as the context. section 2.3.2
  • Automate repeated builds and pushes with a script that invokes podman build against the same context directory. section 2.3.2
  • For podman play kube --build, create a subdirectory matching each image name and place its Containerfile or Dockerfile there. section 8.3.2
$ cat > myapp/Containerfile << _EOF
FROM ubi8/httpd-24
COPY index.html /var/www/html/index.html
_EOF

Shows a minimal Containerfile that consumes index.html from its context directory. section 2.3.2

How Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more covers it

How deep it goes
Defines the directory and demonstrates build commands, file copying, automation, and Kubernetes image-directory matching.
Examples
Demonstrates myapp with index.html and Containerfile, then mysystemd as a Kubernetes image-build directory.
What it assumes
Assumes basic Podman commands and Containerfile or Dockerfile instructions, while demonstrating the directory layout required for builds.
What you can do after
Builds container images from local files and rebuilds images through Podman Kubernetes workflows.
How it connects
Connects Containerfiles, podman build, container images, Kubernetes YAML files, and container registries.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more. The section links point to the parts of the book it draws on.