Explanations of Docker tend to open with scaling and deployment, but its value to you while you are learning is far simpler: you get an environment you can rebuild as many times as you like.
It keeps your machine clean
You want to try Python 3.9 and 3.13 side by side, or install an old library. Do it inside a container and your actual machine is untouched. If the experiment fails, throw the container away and everything is as it was.
Only three commands to learn first
# stand up a disposable room from an image and step inside docker run -it --rm python:3.13 bash # see which rooms are currently running docker ps # list the blueprints for rooms (images) docker images
--rm says to tidy up when you leave. Getting into the habit of adding it while you are learning stops unwanted containers piling up.
A Dockerfile is a note on how to build the room
FROM python:3.13-slim WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt COPY . . CMD ["python", "main.py"]
It is a plain set of instructions, run from the top down. COPY requirements.txt comes first so the cache can be reused as long as the dependencies have not changed.
Where people trip up
- Changes inside a container vanish when it does — put anything you want to keep in a volume or a bind mount
- localhost points at the container itself — open a hole from the host with
-p 8000:8000 - The image is enormous — pick a
-slimbase image