Fix: “docker: command not found” While Updating Ollama (Beginner Guide)

Introduction

I recently tried updating Ollama on my VPS.

Everything seemed straightforward — until I ran:

docker ps 

And got this:

docker: command not found
 That made no sense.

Docker was already installed.
Ollama was running fine.

So why wasn’t the command working?

It turns out, this wasn’t a Docker issue.

It was a mental model problem.

The Real Problem

I was inside a Docker container.

 root@62aaf53zze3a9c8:/#
 

And I was trying to run Docker commands from there.

That doesn’t work.

Understanding the Key Concept (This Changes Everything)

When you work with Docker, you’re dealing with two layers:

🖥️ Host (Your VPS / System)

  • Has Docker installed
  • Controls containers
  • Runs commands like docker ps, docker run, etc.

📦 Container (Where Ollama Runs)

  • Has Ollama
  • Does NOT have Docker
  • Runs application-level commands

👉 Important rule:

TaskWhere to run
Docker commandsHost
Ollama commandsContainer
API callsAnywhere

Why You See “docker: command not found”

Because you are trying to run:

 docker ps
 

Inside the container.

But Docker only exists on the host machine, not inside containers.

Step-by-Step Fix

✅ Step 1 — Exit the container

 exit
 You should now see something like:
 root@srv9zz99258:~#
 

✅ Step 2 — Confirm you’re on the host

 docker ps
 If this works, you’re in the right place.

✅ Step 3 — Stop and remove old container

docker stop ollama
docker rm ollama
 

✅ Step 4 — Pull the latest Ollama image

 docker pull ollama/ollama:latest
 

✅ Step 5 — Run updated container

 docker run -d \
--name ollama \
-p 11434:11434 \
-v ollama:/root/.ollama \
ollama/ollama:latest
 

✅ Step 6 — Verify models

 docker exec -it ollama ollama list
 

Your models (like gemma3, qwen, etc.) should still be there.


✅ Step 7 — Run a model

 docker exec -it ollama ollama run qwen3.5:0.8b

What I Learned (The Real Insight)

This wasn’t a technical issue.

It was a thinking issue.

I was trying to control Docker from inside a container.

Instead of:

Controlling containers from the host.


Final Takeaway

Whenever something feels broken in Docker, ask yourself:

👉 “Am I on the host or inside the container?”

That one question can save hours.


Conclusion

If you’re running Ollama using Docker:

  • Keep Docker commands on the host
  • Keep Ollama commands inside the container

Once you understand this separation, everything becomes much easier.

🚀 If you found this useful, don’t forget to share it with fellow Product Managers and AI Enthusiasts!