- container terminology
- container engines
- container runtimes
- oci compliant images
- union filesystem and overlay2
- container registry
- create a docker hub account
- build and share a container with the class
Great set of general terminology for containers
Typically, the container engine is responsible for:
- Handling user input
- Handling input over an API often from a Container Orchestrator
- Pulling the Container Images from the Registry Server
- Expanding decompressing and expanding the container image on disk using a Graph Driver (block, or file depending on driver)
- Preparing a container mount point, typically on copy-on-write storage (again block or file depending on driver)
- Preparing the metadata which will be passed to the container Container Runtime to start the Container correctly
- Using some defaults from the container image (ex.ArchX86)
- Using user input to override defaults in the container image (ex. CMD, ENTRYPOINT)
- Using defaults specified by the container image (ex. SECCOM rules)
- Calling the Container Runtime
List of major engines:
Links:
A container runtime is responsible for all the parts of running a container that isn't actually running the program itself. As we will see throughout this series, runtimes implement varying levels of features, but running a container is actually all that's required to call something a container runtime.
Links:
- runc oci compliant image
- container runtimes
The Open Container Initiative Runtime Specification aims to specify the configuration, execution environment, and lifecycle of a container.
Links:
An overlay(fs) works very similarly to overhead projection sheets where you have a base sheet that displays something like a worksheet and a sheet above it where you can take your own notes. You can separate the two sheets and you still have your base sheet and your own notes (the difference between the base and your notes).
3 layers:
- Base Layer (Read Only)
- Overlay Layer (Main User View)
- Diff Layer
This is an example of copy-on-write (COW)
Copy-on-write is a strategy of sharing and copying files for maximum efficiency. If a file or directory exists in a lower layer within the image, and another layer (including the writable layer) needs read access to it, it just uses the existing file. The first time another layer needs to modify the file (when building the image or running the container), the file is copied into that layer and modified. This minimizes I/O and the size of each of the subsequent layers.
Links:
A registry server is essentially a fancy file server that is used to store docker repositories. Typically, the registry server is specified as a normal DNS name and optionally a port number to connect to. Much of the value in the docker ecosystem comes from the ability to push and pull repositories from registry servers.
Links:
Create an account on Docker Hub so you can share your container images. Once you have created your account log in to docker hub.
docker login
clone this repository to your local machine. you may need to install git.
git clone https://github.com/allen13/docker-day2.git
make a change in the http hello response section of the code to mark it as your own. This will differntiate the reponses from other classmates.
fmt.Fprintf(w, "Hello from <me> %s!\n", target)
build the docker image
docker build . -t <dockerhub account name>/hello-docker:v0.1.0
# run this to see your the image you built
docker images
# see the oci compliant image config
docker inspect <image name>
run your container
docker run -it --rm -p 8080:8080 <dockerhub account name>/hello-docker:v0.1.0
# navigate to your app. browser works too.
curl localhost:8080
push your container to docker hub
docker push <dockerhub account name>/hello-docker:v0.1.0
post your container name to the class image thread and then run someone eleses image
docker run -it --rm -p 8080:8080 <other dockerhub account name>/hello-docker:v0.1.0
Create a docker container that runs a database and a program that interact with each other without using a second container.
This will require you to:
- Pick a base image with package management built in
- Install your database
- Install the language dependecies for your program
- Build the program if it is not a scripting language
- Install an init system for a container
- Find or write a program that can interact with your choice of database
- Show proof that the program is interacting with the database
Recommended Laguages:
- Python
- Golang
Recommended Databases:
- Redis
- Postgres or MySQL