What You Will Set Up
Every practical lesson runs small Python scripts against three local services. By the end of this lesson your computer will have:
- a practice folder,
~/rag-practice, holding everything the course creates; - a Python virtual environment,
~/rag-practice/.venv, with the course's pinned libraries; - four small models from Hugging Face in
~/rag-practice/hf-cache: three embedding models and one reranker; - Ollama, the application that runs the course's language model,
granite4.1:3b, with its cloud features turned off; - two databases in containers: Qdrant, a dedicated vector database, and PostgreSQL with the pgvector extension.

Everything runs on your own computer and listens only on 127.0.0.1, the
address that other computers cannot reach.
Read the diagram from the left: your scripts talk to each service over HTTP
or the PostgreSQL protocol, always at 127.0.0.1. The two containers keep
their data in named volumes, so deleting and recreating a container does not
delete its data. Ollama runs as an ordinary application, not in a container,
because the course measured it more than ten times slower inside a container
on macOS.
Before you start: you need Python 3.12, 3.13 or 3.14, a container runtime (Docker Desktop on macOS and Windows, or Docker Engine on Linux), 16 GB of memory (recommended), about 15 GB of free disk and a network connection for about 5 GB of one-time downloads. Docker Desktop is free for personal use, education, non-commercial open source and small businesses (fewer than 250 employees and less than $10 million annual revenue); larger organisations need a paid subscription. Docker Engine on Linux has no such terms. Intel Macs and Windows on Arm are not supported, because the pinned PyTorch has no package for them.
Step 1: The Practice Folder and Python
Open a terminal (Terminal on macOS, a shell on Linux, PowerShell on Windows).
If you have not used one for a while, these are the only commands the course
assumes: pwd shows where you are, ls (dir in PowerShell) lists the
folder, cd folder moves into it and mkdir folder creates it.
Check your Python version first. On macOS and Linux:
python3 --version
On Windows:
py --version
You should see Python 3.12, 3.13 or 3.14 followed by a patch number.
The course needs at least 3.12 because NumPy 2.5.4 requires it, and at most
3.14 because the pinned PyTorch publishes no packages for 3.15 yet. If you see
an older or newer version, install a supported one from python.org and use
python3.13 (or py -3.13 on Windows) in the commands below.
Now create the practice folder and the course environment. On macOS and Linux:
mkdir -p ~/rag-practice
cd ~/rag-practice
python3 -m venv .venv
source .venv/bin/activate
On Windows PowerShell:
mkdir $HOME\rag-practice
cd $HOME\rag-practice
py -m venv .venv
.venv\Scripts\Activate.ps1
A virtual environment is a private copy of Python's package folder. Packages
installed while it is active go into ~/rag-practice/.venv and nowhere
else, so the course cannot break other Python projects and is removed by
deleting one folder. Your prompt now starts with (.venv). Every time you
open a new terminal for the course, run the source (or Activate.ps1)
line again; forgetting it is the most common setup failure.
If PowerShell refuses to run Activate.ps1 because "running scripts is
disabled on this system", allow scripts you create yourself for your user
account only, then try again:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
On Debian and Ubuntu, python3 -m venv may fail with a message about
ensurepip; install your distribution's python3-venv package and retry.
Step 2: Install the Pinned Libraries
Install the course libraries in three commands, in this order:
python -m pip install numpy==2.5.4
python -m pip install torch==2.14.1 --index-url https://download.pytorch.org/whl/cpu
python -m pip install sentence-transformers==6.1.0 transformers==5.20.2 faiss-cpu==1.15.1 qdrant-client==1.19.1 httpx==0.28.1 "psycopg[binary]==3.3.6" pgvector==0.5.1 pytest==9.1.1
python -m pip check
These commands are the same in PowerShell. What each line does:
- Exact versions (
==) keep every learner on the versions the course was tested with, so defaults and messages match the lessons. - NumPy first means the next step finds the pinned NumPy already installed and does not bring its own.
- torch from the CPU index.
sentence-transformersruns on PyTorch. On Linux the ordinary torch package is a 555 MB build for NVIDIA GPUs that also pulls in NVIDIA libraries; the PyTorch CPU index serves a much smaller CPU-only build. On macOS and Windows the CPU index serves the same build as the ordinary one, so one command works everywhere. Each command uses one package index, which keeps the two indexes from mixing in one resolution. - The rest from PyPI: sentence-transformers and transformers run the
embedding and reranking models; faiss-cpu is a library of vector indexes;
qdrant-client talks to Qdrant; httpx sends HTTP requests to Ollama;
psycopg with its
binaryextra talks to PostgreSQL without a separate client library; pgvector teaches psycopg the vector type; pytest runs tests. pip checkconfirms that every installed package's own requirements are met. It should printNo broken requirements found.
The environment takes about 1.2 GB. On a slow network pip may stop with
ReadTimeoutError ... Read timed out. That is pip's 15-second default timeout,
not a broken package. Run the same command again with a longer timeout and
retries; what already downloaded is not fetched again:
python -m pip install --timeout 120 --retries 10 sentence-transformers==6.1.0 transformers==5.20.2 faiss-cpu==1.15.1 qdrant-client==1.19.1 httpx==0.28.1 "psycopg[binary]==3.3.6" pgvector==0.5.1 pytest==9.1.1
Step 3: Download the Models
The course uses four small models published on Hugging Face under the Apache-2.0 or MIT licence. None needs an account. Each is pinned to an exact revision, a commit ID in the model's repository, so the files you download are the files the course was tested with even if the publisher changes the model later.
Make a folder for this lesson's scripts:
mkdir -p ~/rag-practice/course-environment
cd ~/rag-practice/course-environment
(In PowerShell: mkdir $HOME\rag-practice\course-environment and
cd $HOME\rag-practice\course-environment.)
Save this as download_models.py in ~/rag-practice/course-environment:
"""Download the course's pinned models into ~/rag-practice/hf-cache."""
import os
from pathlib import Path
PRACTICE = Path.home() / "rag-practice"
os.environ["HF_HOME"] = str(PRACTICE / "hf-cache")
os.environ.setdefault("HF_HUB_DOWNLOAD_TIMEOUT", "60")
from huggingface_hub import snapshot_download # noqa: E402 (imported after HF_HOME is set)
MODELS = {
"sentence-transformers/all-MiniLM-L6-v2": "1110a243fdf4706b3f48f1d95db1a4f5529b4d41",
"BAAI/bge-small-en-v1.5": "5c38ec7c405ec4b44b94cc5a9bb96e735b38267a",
"ibm-granite/granite-embedding-small-english-r2": "2ab6fa8ea2d674564defd37171ae19079b864b33",
"mixedbread-ai/mxbai-rerank-xsmall-v1": "b5c6e9da73abc3711f593f705371cdbe9e0fe422",
}
WANTED = ["*.json", "*.txt", "model.safetensors", "1_Pooling/*", "2_Normalize/*", "tokenizer*", "*.model"]
for repo, revision in MODELS.items():
folder = Path(snapshot_download(repo, revision=revision, allow_patterns=WANTED))
size = sum(f.stat().st_size for f in folder.rglob("*") if f.is_file())
print(f"{repo:48} {revision[:8]} {size / 1e6:6.1f} MB")
How the script works:
HF_HOMEtells the Hugging Face libraries where to keep downloads. It must be set beforehuggingface_hubis imported, because the library reads it once at import time; that is why the import comes after the assignment. Keeping the cache inside~/rag-practicemeans the course's downloads live in one folder that cleanup can remove.HF_HUB_DOWNLOAD_TIMEOUTraises the wait for a slow server from the default 10 seconds to 60.setdefaultkeeps any value you set yourself.snapshot_download(repo, revision=..., allow_patterns=...)downloads the files of one repository at one revision and returns the local folder.WANTEDkeeps configuration, tokenizer andmodel.safetensorsfiles and skips everything else. Several of these repositories also holdpytorch_model.bin, a pickle file: loading a pickle can run arbitrary code, so the course downloads only the safetensors format, which stores numbers and nothing executable.- The loop prints each repository, the first eight characters of its revision and the size on disk.
Run it with the environment active:
python download_models.py
Illustrative output (sizes are what the course measured; your progress bars differ):
sentence-transformers/all-MiniLM-L6-v2 1110a243 91.6 MB
BAAI/bge-small-en-v1.5 5c38ec7c 134.4 MB
ibm-granite/granite-embedding-small-english-r2 2ab6fa8e 98.9 MB
mixedbread-ai/mxbai-rerank-xsmall-v1 b5c6e9da 152.8 MB
If a download stops making progress, press Ctrl+C and run the script again:
finished files are kept and the download resumes. If it fails repeatedly on a
slow connection, set a longer timeout first (export HF_HUB_DOWNLOAD_TIMEOUT=300 on macOS and Linux, $env:HF_HUB_DOWNLOAD_TIMEOUT = "300" in PowerShell).
Step 4: Check the Environment
Save this as check_setup.py in ~/rag-practice/course-environment:
"""Check the course environment: interpreter, library versions and models."""
import os
import sys
from importlib.metadata import version
from pathlib import Path
PRACTICE = Path.home() / "rag-practice"
os.environ["HF_HOME"] = str(PRACTICE / "hf-cache")
os.environ["HF_HUB_OFFLINE"] = "1" # use only the downloaded files
EXPECTED = {"numpy": "2.5.4", "torch": "2.14.1", "sentence-transformers": "6.1.0", "transformers": "5.20.2",
"faiss-cpu": "1.15.1", "qdrant-client": "1.19.1", "httpx": "0.28.1", "psycopg": "3.3.6",
"pgvector": "0.5.1", "pytest": "9.1.1"}
EMBEDDERS = {
"sentence-transformers/all-MiniLM-L6-v2": "1110a243fdf4706b3f48f1d95db1a4f5529b4d41",
"BAAI/bge-small-en-v1.5": "5c38ec7c405ec4b44b94cc5a9bb96e735b38267a",
"ibm-granite/granite-embedding-small-english-r2": "2ab6fa8ea2d674564defd37171ae19079b864b33",
}
RERANKER = ("mixedbread-ai/mxbai-rerank-xsmall-v1", "b5c6e9da73abc3711f593f705371cdbe9e0fe422")
print(f"Python {sys.version.split()[0]}")
print(f"Interpreter {sys.executable}")
in_env = Path(sys.prefix).resolve() == (PRACTICE / ".venv").resolve()
print(f"Course environment active: {in_env}")
problems = 0 if in_env else 1
for package, wanted in EXPECTED.items():
found = version(package) # reads the installed metadata without importing the package
flag = "ok" if found.split("+")[0] == wanted else f"expected {wanted}"
problems += flag != "ok"
print(f"{package:22} {found:14} {flag}")
from sentence_transformers import CrossEncoder, SentenceTransformer # noqa: E402
for repo, revision in EMBEDDERS.items():
model = SentenceTransformer(repo, revision=revision, device="cpu")
print(f"{repo:48} {model.get_embedding_dimension()} dimensions, input limit {model.max_seq_length} tokens")
reranker = CrossEncoder(RERANKER[0], revision=RERANKER[1], device="cpu")
score = float(reranker.predict([("Is PVC allowed on the laser?", "PVC is not allowed on the laser cutter.")])[0])
print(f"{RERANKER[0]:48} test score {score:.3f}")
print("Setup check passed" if problems == 0 else f"Setup check found {problems} problem(s)")
sys.exit(1 if problems else 0)
The parts that matter:
HF_HUB_OFFLINE=1forbids network calls, so a model loads only if all its files are already in the cache. The check therefore proves the downloads are complete, and later lessons work without a network.sys.prefixis the folder of the running environment. Comparing it with~/rag-practice/.venvcatches the wrong-interpreter mistake.importlib.metadata.versionreads a package's version from its installed metadata without importing it. That matters for faiss-cpu: on macOS, importing FAISS and PyTorch in the same Python process crashed or hung in the course's tests, because each brings its own copy of a threading library (OpenMP). Course scripts therefore never import both; this check imports neither FAISS nor anything that would load it. The+split ignores a build suffix such as+cputhat Linux and Windows add to torch.- Loading each model confirms its files, then prints its dimension (the length of every vector it produces) and its input limit in tokens. The reranker scores one question and passage pair; any finite number shows it runs.
- The exit code is 0 when everything matches and 1 otherwise, so other scripts can use the check.
Run it:
python check_setup.py
Illustrative output on macOS (paths and patch versions differ; Linux and
Windows show 2.14.1+cpu for torch):
Python 3.13.5
Interpreter /Users/you/rag-practice/.venv/bin/python
Course environment active: True
numpy 2.5.4 ok
torch 2.14.1 ok
sentence-transformers 6.1.0 ok
...
pytest 9.1.1 ok
sentence-transformers/all-MiniLM-L6-v2 384 dimensions, input limit 256 tokens
BAAI/bge-small-en-v1.5 384 dimensions, input limit 512 tokens
ibm-granite/granite-embedding-small-english-r2 384 dimensions, input limit 8192 tokens
mixedbread-ai/mxbai-rerank-xsmall-v1 test score 0.796
Setup check passed
What to look at: Course environment active: True, every line ending in
ok, and the three models' dimensions and limits. Between these lines you
will also see Loading weights progress bars and, for the Granite model, a
FutureWarning that torch.jit.script is deprecated: it comes from inside the
model's code and does not affect the course.
Step 5: Ollama and the Course Model
Ollama runs language models on your computer and answers HTTP requests on
127.0.0.1:11434. It is free and needs no account for local models. Install
it from the vendor's instructions for your system (S18 to S20):
- macOS 14 or later: download
Ollama.dmg, drag Ollama to Applications and start it. It can run on the Apple GPU. - Windows 10 22H2 or later: run
OllamaSetup.exe. It installs in your home folder and does not need Administrator rights; the installer is large (about 1.7 GB) because it includes GPU libraries. - Linux: follow the install script or the manual archive instructions on
the Ollama Linux page; both use
sudo.
Ollama can also send prompts to models hosted in Ollama's cloud and search the
web. The course keeps everything on your computer, so turn those features
off. Save this as ollama_cloud_off.py in ~/rag-practice/course-environment:
"""Turn off Ollama's cloud features in ~/.ollama/server.json, keeping other settings."""
import json
from pathlib import Path
path = Path.home() / ".ollama" / "server.json"
settings = json.loads(path.read_text(encoding="utf-8")) if path.exists() else {}
settings["disable_ollama_cloud"] = True
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(settings, indent=2) + "\n", encoding="utf-8")
print(f"Wrote {path}: {settings}")
print("Now quit and restart Ollama so it reads the setting.")
The script reads any existing settings file, sets disable_ollama_cloud to
true and writes the file back, so other settings survive. Run it, then quit
Ollama (from its menu-bar or system-tray icon, or sudo systemctl restart ollama on Linux) and start it again:
python ollama_cloud_off.py
Ollama's log then contains the line Ollama cloud disabled: true; on macOS
the log is ~/.ollama/logs/server.log. Now download the course model, about
2.1 GB, and list what is installed:
ollama pull granite4.1:3b
ollama list
granite4.1:3b is IBM's Granite 4.1 model with about 3 billion parameters,
published under Apache-2.0 and stored in a compressed 4-bit form. In the
course's tests it gave about 2 seconds per answer on an Apple GPU and about
6 seconds on four CPU cores. ollama list shows its ID; the first 12
characters should be 6fd349357287, the digest the course was tested with.
Step 6: Two Databases in Containers
A container runs a program from an image, a packaged file system with the program and everything it needs, isolated from the rest of your computer. You need only a few commands:
| Command | What it does |
|---|---|
docker pull IMAGE | Download an image |
docker run -d --name NAME -p 127.0.0.1:HOST:CONTAINER -v VOLUME:PATH IMAGE | Start a container in the background with a name, a published port and a named volume |
docker ps | List running containers |
docker logs NAME | Show a container's output |
docker port NAME | Show where its ports are published |
docker stop NAME, docker start NAME | Stop and start it again; data in volumes stays |
docker rm NAME | Remove a stopped container (its named volume stays) |
Start Docker Desktop (or check docker version on Linux), then download the
two pinned images and check their digests:
docker pull qdrant/qdrant:v1.19.2
docker pull pgvector/pgvector:0.8.7-pg18-trixie
docker image inspect --format "{{index .RepoDigests 0}}" qdrant/qdrant:v1.19.2 pgvector/pgvector:0.8.7-pg18-trixie
Expected output (the same on every platform, because these are the digests of each tag's multi-platform index):
qdrant/qdrant@sha256:b7b0444c4c351c970b98e90a6f89c2ee4287c65b44e52b4cb503fa5b2aa927ad
pgvector/pgvector@sha256:9d9c930220cb9bf2f956d10a8f909cf9973d9672ca0278aef2c1e6facccad2e0
A digest is a fingerprint of the image's contents. If yours differs, the tag
was moved to different contents, which may behave differently from the
lessons. Pull the tested image by its digest instead, for example
docker pull qdrant/qdrant@sha256: followed by the digest shown above, and
use that same name@sha256:... reference wherever a later command names the
image.
Start Qdrant:
docker run -d --name rag-course-qdrant -p 127.0.0.1:6333:6333 -v rag-course-qdrant:/qdrant/storage qdrant/qdrant:v1.19.2
Each part of the command:
-druns the container in the background;--name rag-course-qdrantgives it a name the course uses to find it and, at the end, to remove it.-p 127.0.0.1:6333:6333publishes the container's port 6333 on your computer's port 6333 on the loopback address only. Without the127.0.0.1:prefix Docker publishes on every network interface, and a self-hosted Qdrant without an API key accepts requests from anyone who can reach it.-v rag-course-qdrant:/qdrant/storagecreates (if needed) a named volume and mounts it where Qdrant stores data, so collections survive the container being stopped or replaced.
PostgreSQL needs a password for its postgres user. Rather than type one into
a command, generate a random one into a file.
Save this as make_postgres_env.py in ~/rag-practice/course-environment:
"""Create ~/rag-practice/postgres.env with a random password for the course database."""
import secrets
from pathlib import Path
path = Path.home() / "rag-practice" / "postgres.env"
if path.exists():
print(f"{path} already exists; keeping it")
else:
path.write_text(f"POSTGRES_PASSWORD={secrets.token_urlsafe(24)}\n", encoding="utf-8")
path.chmod(0o600) # readable by you only, where the file system supports it
print(f"Wrote {path}")
secrets.token_urlsafe(24) makes a random 32-character password. The script
never overwrites an existing file, because the database keeps the password it
was created with. Run it, then start PostgreSQL with that file as its
environment:
python make_postgres_env.py
docker run -d --name rag-course-postgres -p 127.0.0.1:5432:5432 --env-file ~/rag-practice/postgres.env -v rag-course-postgres:/var/lib/postgresql pgvector/pgvector:0.8.7-pg18-trixie
In PowerShell, write the file path as $HOME\rag-practice\postgres.env.
--env-file passes POSTGRES_PASSWORD into the container, where the image
uses it once, when it creates the database. The volume is mounted at
/var/lib/postgresql: PostgreSQL 18 images keep their data in
/var/lib/postgresql/18/docker, so older instructions that mount
/var/lib/postgresql/data would leave the data outside the volume. If port
5432 is already used by another PostgreSQL on your computer, docker run
fails with port is already allocated. The course's scripts connect to port
5432, so stop the other server while you work on the course's PostgreSQL
lessons.
Confirm both containers and their ports:
docker ps
docker port rag-course-qdrant
docker port rag-course-postgres
Illustrative docker port output:
6333/tcp -> 127.0.0.1:6333
5432/tcp -> 127.0.0.1:5432
127.0.0.1 on the right-hand side is what you are checking: neither service
is reachable from another computer.
Step 7: Check the Services
Save this as check_services.py in ~/rag-practice/course-environment:
"""Check the course services: Ollama, Qdrant and PostgreSQL with pgvector."""
import json
import sys
from pathlib import Path
import httpx
import psycopg
PRACTICE = Path.home() / "rag-practice"
MODEL, DIGEST = "granite4.1:3b", "6fd349357287"
def ollama():
version = httpx.get("http://127.0.0.1:11434/api/version", timeout=5).json()["version"]
models = {m["name"]: m["digest"] for m in httpx.get("http://127.0.0.1:11434/api/tags", timeout=5).json()["models"]}
if MODEL not in models:
raise LookupError(f"{MODEL} is not pulled; run: ollama pull {MODEL}")
if not models[MODEL].startswith(DIGEST):
raise ValueError(f"{MODEL} has digest {models[MODEL][:12]}, expected {DIGEST}")
return f"version {version}; {MODEL} digest {DIGEST}"
def ollama_cloud():
path = Path.home() / ".ollama" / "server.json"
if path.exists() and json.loads(path.read_text(encoding="utf-8")).get("disable_ollama_cloud") is True:
return f"turned off in {path}"
raise RuntimeError("run ollama_cloud_off.py, then restart Ollama")
def qdrant():
return "version " + httpx.get("http://127.0.0.1:6333/", timeout=5).json()["version"]
def postgres():
password = (PRACTICE / "postgres.env").read_text(encoding="utf-8").strip().split("=", 1)[1]
with psycopg.connect(host="127.0.0.1", port=5432, user="postgres", password=password,
dbname="postgres", connect_timeout=5, autocommit=True) as conn:
conn.execute("CREATE EXTENSION IF NOT EXISTS vector")
server = conn.execute("SHOW server_version").fetchone()[0].split()[0]
vector = conn.execute("SELECT extversion FROM pg_extension WHERE extname = 'vector'").fetchone()[0]
return f"PostgreSQL {server}; pgvector {vector}"
failures = 0
for name, check in [("Ollama", ollama), ("Ollama cloud", ollama_cloud), ("Qdrant", qdrant), ("PostgreSQL", postgres)]:
try:
print(f"{name:13} OK {check()}")
except Exception as exc: # report every service, not just the first failure
failures += 1
print(f"{name:13} FAIL {type(exc).__name__}: {exc}")
print("All services OK" if failures == 0 else f"{failures} service check(s) failed")
sys.exit(1 if failures else 0)
This is your first HTTP code, so read one call slowly.
httpx.get("http://127.0.0.1:11434/api/version", timeout=5) sends a GET
request to Ollama's version endpoint and waits at most five seconds; .json()
turns the JSON reply, {"version": "0.40.7"}, into a Python dictionary.
/api/tags returns the installed models; the script checks the course model
and its digest. Qdrant's root address returns its name and version in the same
way. For PostgreSQL the script reads the password from postgres.env,
connects with psycopg, enables the vector extension (the command does
nothing if it is already enabled) and reads the extension's version. Each
check runs inside try, so one stopped service does not hide the others.
Run it (the database needs a few seconds after docker run before it accepts
connections):
python check_services.py
Illustrative output:
Ollama OK version 0.40.7; granite4.1:3b digest 6fd349357287
Ollama cloud OK turned off in /Users/you/.ollama/server.json
Qdrant OK version 1.19.2
PostgreSQL OK PostgreSQL 18.6; pgvector 0.8.7
All services OK
When a Check Fails
| What you see | Likely cause | Safe next step |
|---|---|---|
Course environment active: False, or ModuleNotFoundError | The environment is not active in this terminal | Run the source or Activate.ps1 line again; check which python (Get-Command python in PowerShell) points inside ~/rag-practice/.venv |
| pip downloads a 555 MB torch with NVIDIA packages on Linux | torch was installed without the CPU index | Uninstall torch and repeat step 2's torch line exactly |
No matching distribution found for numpy==2.5.4 | Python older than 3.12 or newer than 3.14 | Install a supported Python and recreate the environment |
| A model download stops at the same size | A stalled connection | Ctrl+C, raise HF_HUB_DOWNLOAD_TIMEOUT, run again; it resumes |
Ollama FAIL ConnectError | Ollama is not running | Start the Ollama application (or systemctl start ollama) |
Ollama FAIL LookupError: ... is not pulled | The model is missing (Ollama's API answers 404 for it) | ollama pull granite4.1:3b |
port is already allocated from docker run | Another program uses the port | Stop that program, or remove the half-created container with docker rm rag-course-postgres before retrying |
Qdrant FAIL with No space left on device in docker logs rag-course-qdrant | Docker Desktop's virtual disk is full, even if your drive is not | docker system df shows what uses it; remove only images and containers you created and recognise, or raise the disk limit in Docker Desktop's settings. Never run broad prune commands to fix it |
docker system df is safe: it only reports. Removing things is not, so remove
only what you can name.
Your Turn: Prove the Data Persists
Show that a Qdrant collection survives a container restart. With the environment active, create a small test collection:
python -c "from qdrant_client import QdrantClient, models; c = QdrantClient('http://127.0.0.1:6333'); c.create_collection('rag-course-persistence-test', vectors_config=models.VectorParams(size=4, distance=models.Distance.COSINE)); print(c.collection_exists('rag-course-persistence-test'))"
Now restart the container, wait a few seconds, and predict what the same check prints before you run it:
docker restart rag-course-qdrant
python -c "from qdrant_client import QdrantClient; print(QdrantClient('http://127.0.0.1:6333').collection_exists('rag-course-persistence-test'))"
Then diagnose these four outputs from other learners without running anything:
check_setup.pyprintsInterpreter /usr/bin/python3andCourse environment active: False.download_models.pyhas shown the same progress for ten minutes.docker runfor PostgreSQL ends withBind for 127.0.0.1:5432 failed: port is already allocated.check_services.pyprintsQdrant FAIL, and the Qdrant log saysNo space left on device.
Answers
The collection still exists after the restart: True. The container was
stopped and started, but the collection lives in the rag-course-qdrant
volume, not in the container. Remove the test collection when you have seen
it:
python -c "from qdrant_client import QdrantClient; print(QdrantClient('http://127.0.0.1:6333').delete_collection('rag-course-persistence-test'))"
- The system Python ran the script: the environment was not activated in this terminal. Activate it and rerun.
- A stalled download. Stop it with Ctrl+C and run the script again with a
longer
HF_HUB_DOWNLOAD_TIMEOUT; finished files are kept. - Another PostgreSQL server already uses port 5432. The failed command may
have left a stopped container named
rag-course-postgres; remove it withdocker rm rag-course-postgres, free the port, and start it again. - Docker Desktop's virtual disk is full. Check
docker system df, remove only images, containers or volumes you created and can name, or raise the disk limit in Docker Desktop's settings.
Reset and Cleanup
Keep everything this lesson created: the environment, the model cache, Ollama
with granite4.1:3b, both containers and both volumes are used by later
lessons. Only the test collection should be gone.
To stop the databases between study sessions, run docker stop rag-course-qdrant rag-course-postgres; docker start with the same names
brings them back with their data. If you need to start this lesson again from
the beginning, remove only what it created, by name:
docker rm -f rag-course-qdrant rag-course-postgres
docker volume rm rag-course-qdrant rag-course-postgres
and delete ~/rag-practice (it holds the environment, models and
postgres.env). The final challenge lists every step to remove the whole
course setup, including the Ollama model.