This is hardly a complete guide but some people asked about Docker and kubernetes and wanted to shared my thoughts. I’ll make this a wiki page if people want to add/correct my breakdown.
Docker is a ‘container’ which essentially allows you run a very lightweight application sandboxed away from the host operating system. It’s has a lot more concepts built into then a Linux chroot but at the core of it it shared some similarities. It allows to setup an environment that prevents the user from accessing resources on the host unless explicitly allowed.
We can define a new docker Image by creating a docker file.
FROM alpine RUN apk update && \ apk add bash vim CMD sleep 9999
Now, let’s build the image.
docker build --tag=testing .
That creates a new image called testing which will execute sleep 9999 and then exit once it’s done.
To run the image you can type:
docker run testing
Each line in the docker file is a ‘layer’ so if you modify the Dockerfile and add the following line above the CMD
Then it’ll only execute the lines
USER guest CMD sleep 9999
on top of the previous layer that has already been executed.
once the container is running, you can also drop into the running container to inspect or modify the OS though keep in mind any changes done this way will go away once you remove the container and a new contrainer is created from the existing image.
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 41cdf9830910 testing "/bin/sh -c 'sleep 9…" 19 minutes ago Up 19 minutes condescending_golick
Then i can drop inside the container by running:
docker exec -it 41cdf9830910 sh
- docker compose
- docker networking