From adc1f4b1c086aab26ecfc258ad788002a7ef41cc Mon Sep 17 00:00:00 2001 From: JasonHomeWorkstationUbuntu Date: Sun, 29 Nov 2020 17:16:03 +1100 Subject: [PATCH] 4.1 Docker the program --- notes/4_under_the_hood.md | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 notes/4_under_the_hood.md diff --git a/notes/4_under_the_hood.md b/notes/4_under_the_hood.md new file mode 100644 index 0000000..64d7ae1 --- /dev/null +++ b/notes/4_under_the_hood.md @@ -0,0 +1,41 @@ +# 4. Under the Hood + +## Docker the program + +### What Kernels Do + +* software core of computer +* Run directly on hardware, had many jobs + * Respond to messages from the hardware + * Start and schedule programs + * Control and organize storage + * Pass messages between programs + * Allocate resources, memory, CPU, network, etc + * **Create containers by Docker configuring the kernel** + +### What Docker Does + +* Program written in Go +* Manages kernel features + * Docker uses "cgroups" to contain processes, so each container (with its process) is isolated + * Docker uses "namespaces" (feature of Linux Kernel) to contain networks + * USes "copy-on-write" filesystems to build images +* Above features has been used by industry for years before Docker. + +### What Docker Really Does + +* Makes scripting distributed systems "easy" + +### The Docker Control Socket + +* Docker is two programs: a **client** & a **server** + * They communicate via a socket +* The server receives commands over a socket (either over a network or through a "file") + * When client & server are on same computer, a special "file" `socket` is created for communication +* The client can even run inside a docker container itself + +location of docker socket file on linux: `/var/run/docker.sock` + +We can control the docker server using docker client inside a container: `docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock docker sh` + +## \ No newline at end of file