liveBook · Manning

Container

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

A container is an isolated execution environment that packages an application with its dependencies while sharing the host operating system kernel.

A container is a virtualized server that can host a microservice. Containers isolate services from one another while dividing a computer’s resources among them. Compared with a virtual machine, which includes a complete operating system on fully virtualized hardware, a container is smaller and uses computing resources more efficiently. section 3.3

A Docker image is the bootable snapshot; a container is the running instance created from it. The image holds the microservice’s code, dependencies, and assets and is immutable. After it starts as a container, its filesystem can be modified. section 3.4

To test a packaged microservice before publishing it:

  • Build its image from a Dockerfile, then use docker run to start a local container. section 3.8 section 3.12
  • Check the resulting container ID, inspect it with docker container list, and use docker logs with that ID to read its output. section 3.8.3
  • If it misbehaves, open a shell with docker exec -it <container-id> bash; use commands such as ls and ps to inspect its files and process. section 3.8.4
cd chapter-3/example-1
docker run -d -p 3000:3000 -e PORT=3000 video-streaming

This runnable command starts the video-streaming image in the background, forwards host port 3000 to container port 3000, and sets PORT=3000 inside the container. section 3.8.3

Once tested, the image can be published to a private container registry for later deployment to a Kubernetes cluster. Running one container locally verifies the microservice before that production step. section 3.6 section 3.8.3

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Defines containers, contrasts them with virtual machines and images, then gives commands for running, inspecting, and debugging one.
Examples
Uses a video-streaming microservice, a docker run command with port forwarding, container listings, logs, and shell inspection.
What it assumes
Assumes Docker is installed and a microservice is ready to package; defines containers and images before running one.
What you can do after
Operate/configure it with Docker to start a local microservice container, check its output, and inspect problems from inside.
How it connects
Connects containers to microservices, virtual machines, Docker images, container registries, and Kubernetes.

Also explained in

Compare how 27 books explain container →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.