Docker - Notes04 Jan 2019
A container is launched by running an image.
A container is a runtime instance of an image - what the image becomes in memory when executed (that is, an image with state, or a user process).
To recap, while typing docker run is simple enough, the true implementation of a container in production is running it as a service. Services codify a container’s behavior in a Compose file, and this file can be used to scale, limit, and redeploy our app.
NOTE: it’s not necessary to initialize a swarm to use
Services are really just “containers in production.” A service only runs one image, but it codifies the way that image runs — what ports it should use, how many replicas of the container should run so the service has the capacity it needs, and so on.
A single container running in a service is called a task. Tasks are given unique IDs that numerically increment, up to the number of replicas you defined in docker-compose.yml.
container state is persisted in
container's writable layer even if no volume
is defined and mounted for the service:
Volumes are often a better choice than persisting data in a container’s writable layer, because a volume does not increase the size of the containers using it, and the volume’s contents exist outside the lifecycle of a given container.