This is first in ongoing series about how AI has helped me. Many people are either skeptical that AI is useful or just do not know how what to do with it. I too am still learning how to use AI in my life, and documenting what I’ve done should provide a useful resource, both for others and for future me.
With the help of Claude, I am starting to get my head around the basics of Docker. I have previously made comments in conversation about how I find Docker confusing (I tried it once several years ago) and people unhelpfully reply by telling me it is simple. Either they do not realise they do not understand or they take for granted all their knowledge.
To indicate how it is not simple, here are different questions I had or concepts that came up, in my first hour of learning about Docker with Claude:
Containers, images, dockerfiles and registries
Flask and web apps
Linux distributions
slim variants, Debian, Alpine, Ubuntu
Layers in an image
What does it mean to ‘build an image’
What kind of object is an image? What is its datatype?
GPG keys, `/bin/sh -c set -eux`
Virtual disks
Stopping vs exiting vs deleting vs restarting vs removing a container
Isolation
Docker engine
Namespace
Resource allocation
Network ports
DinD
Sockets
Orchestration
Daemons
VMs, hypervisor
How can I run Linux containers on a Mac?
Userspaces, kernels, rings
I know that I do not need to understand the majority of these concepts, but a priori it is hard to know what I do or do not need to understand. For example, here is something that I learnt and I think *is* worth understanding but I suspect most people do not know: it is often said that containers and VMs are separate things, but, in order for Docker to run Linux containers on a non-Linux machine, the Docker engine creates a Linux VM behind the scenes first!
The amazing thing about Claude is I can just keeping asking it questions and it continues to give helpful answers. Previously, I would have had to google around, sifting through similarly phrased questions on StackOverFlow, crappy blogposts over-flowing with ads and 3-hour YouTube tutorials, just to answer one simple question. Now, I just ask Claude. It has a consistent tone, has context of what we have already discussed, and will answer exactly the question I ask.
The conversation with Claude
For those interested, here is most of the conversation I had with Claude.
I asked it to guide me through a beginner tutorial on Docker, telling it I know basic Python.
It listed Containers, Images, Dockerfiles and Registries as core concepts with brief descriptions (which I didn’t understand), and it gave basic exercise to create a container:
It also gave a second exercise that used Flask apps. I skipped this as I am unfamiliar with Flask and web apps.
I ask how to check if I have docker installed and it mentions a ‘Docker daemon’ in its answer. I just move on to try the exercises.
When I run `docker build -t first-app .` I get an error. I am using Cursor so just get the LLM within Cursor to debug without having to copy error messages around. It tells me I have to first open Docker Desktop.
It then all works and I ask Claude to explain each line of the code. I honestly did not understand most of the explanation.
I ask it what ‘FROM’ means, and it gives some explanation. I’m starting to get somewhere, but still confused.
I ask it what an ‘image’ is. It gives an explanation, but still not clear to me.
I asked what it means to build an image. Still unsure but slowly making progress.
I ask Claude what kind/type of object an image is, hoping for it to be more concrete.
I run the command to see the layers. I do not understand most of this, especially why there are things from 2 or 3 weeks ago.
I ask Claude and I kind of follow it.
I ask if I need to understand code like ‘GPG_KEY’ or ‘/bin/sh -c set -eux…’ and it says these are advanced concepts and I should focus on other things
I’m still unsure what an image is though so ask Claude for more.
More progress! I ask a question to check my understanding.
It mentioned ‘virtual disk’. May as well ask. But difficult to understand.
I decide to move on to `docker run`. I make a mistake in my question which Claude corrects.
I ask a couple of follow-ups.
Difference between image and container?
It gives an analogy which I think is bad. Presumably, this analogy is used elsewhere in the internet, for Claude to use it. But unlike the Internet, I can just ask Claude about it!
Where is the container?
I ask if you can have containers inside containers. It just opens another can of worms that I do not dive into.
I am back to the ‘daemon’ it mentioned much earlier.
What’s the point of all this? It gives great answer!
At this point I figure I’ll give Docker’s official documentation a go. The basics of what a container is. It does not start well: the first line is “Imagine you're developing a killer web app that has three main components - a React frontend, a Python API, and a PostgreSQL database.” This is clearly intended for software engineers - I have maths and DS background and have not had to create any of these components before. I do get some insight, which is that each of these components gets its own container. That is not evident from the beginner tutorial. It also gives comparison to VMs, which I do not understand, because the explanation of ‘FROM’ from Claude seems to imply choosing an OS.
So I ask Claude!
Totally not obvious but important: Docker creates a Linux VM!
I go down small rabbit hole about userspace. This includes skimming the resource “The Linux Journey”.
And I decide to stop and do a review.
I've always had the same feeling about Docker and used it with a lingering sense of dissatisfaction caused by not fully understanding what’s happening behind the magic of the "docker daemon".
I never thought of discussing about it with Claude before, but apparently I should have, because now it’s much clearer!