---
# System prepended metadata

title: Docker

---

# Docker
- a development tool and a runtime environment

## Docker container image
- A container always starts with an image
- an instantiation of that image

### Image
- a static specification of what the container should be in runtime
    - including the application code inside the container and runtime configuration settings
- contain read-only layers, which means that once an image is created it is never modified

    - an Ubuntu image with an Apache installation
![](https://i.imgur.com/iAcXScY.png)

## Running Docker container
- an instantiation of an image
- Containers derived from the same image are identical to each other in terms of their application code and runtime dependencies 
- include a writable layer (the container layer) on top of the read-only content
- Runtime changes, including any writes and updates to data and files, are saved in the container layer
- **Same image have container layers that differ substantially**

```
docker commit
```
- When a running container is deleted, the writable container layer is also deleted and will not persist
- run before delete the container, which is able to persist change
-> the running container content, including the writable layer, is written into a new container image and stored to the disk
1. create a successive, discrete set of Docker images, each built on top of the previous image
2. copy-on-write strategy to minimize the storage footprint of containers and images that share the same base components
    * optimize storage space and minimize container start time

![](https://i.imgur.com/aDqLtvP.png)

```
docker -ps
# Docker will return a list of containers running on the daemon
# daemon: thin layer between the containers and the Linux kernel
# the persistent runtime environment that manages application containers
```

## Dockerfile
- build container images, which then become the basis of running container
- a text document that contains all of the configuration information and commands needed to assemble a container image
- simplifies the steps for container creation

## Content distribution with Docker
![](https://i.imgur.com/K3XeXx7.png)

## The immutability of Docker containers
Benefits:
1. Version control
2. Cleaner updates and more manageable state changes
3. Minimized drift

## IAAS/SAAS/PAAS
![](https://i.imgur.com/haY7Y4I.png)
