liveBook · Manning

State

As explained in Road to Kubernetes

State is the persistent data or condition that determines how software behaves across operations or restarts.

State is the data or condition that persists between operations and influences later behavior. Databases are stateful because their data must survive machine or container destruction; the Python and Node.js applications are stateless because their environments can be recreated. section 5.1.4

Deployment examples show several ways to preserve or provide state:

  • Treat database data as persistent state and protect it with backup data. section 5.1.4
  • Use container volumes to preserve data even when a container stops or is destroyed. section 6.0
  • Use environment variables for API keys, secret credentials, and connections to external database services. section 6.0
  • Compare desired, current, and updated state when Ansible applies declared tasks to hosts. section 4.2.2

A container that forgets NGINX

Installing NGINX interactively inside an Ubuntu container works only temporarily. After the container exits, running it again produces “No such file or directory” and “command not found,” demonstrating why container changes must be made through a reproducible image rather than long-term manual modification. section 5.1.4

docker run --rm -it ubuntu /bin/bash
cat /etc/nginx/sites-available/default
nginx -v
exit

Inspect the commands used to enter a temporary Ubuntu container, examine NGINX configuration, check its version, and exit. section 5.1.4

How Road to Kubernetes covers it

How deep it goes
Demonstrates persistence through database backups, Docker volumes, environment variables, and Ansible desired-state reporting.
Examples
Uses database data, recreated Python and Node.js environments, an interactive NGINX container, Docker volumes, and Ansible tasks.
What you can do after
Operate/configure containers with volumes and environment variables, and distinguish reproducible stateless workloads from persistent stateful services.
How it connects
Connects state with stateless containers, stateful applications, Docker volumes, environment variables, Docker Compose, and Ansible.

Also explained in

Compare how 39 books explain state →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.