Member-only story

Ollama: Starter Ollama Cheatsheet

Keep in touch | GEN AI Series

Rahul S
1 min readMar 31, 2024

(updated: 31th March 2024)

  1. Pull ollama docker image
docker pull ollama/ollama

2. Run ollama container in docker (useful for microservice applications)

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

This command starts a container based on the Ollama image and maps port 11434 on local/root machine to port 11434 inside the container.

The -it flag attaches an interactive terminal to the container.

3. Run llama2 model locally

docker exec -it ollama ollama run llama2

docker exec -it ollama: This Docker command executes a command inside a running container named “ollama” with the options -it.

The command being executed inside the container is “ollama run llama2”. It interacts with the container’s standard input/output and runs a program or script called “llama2” within the “ollama” container.

4. We should be able to check, if ollama is running successfully by calling http://localhost:11434

Basic Ollama Comamnds:

  • ollama pull — pull a model from the Ollama model hub.
  • ollama rm — removes the already downloaded model from the local computer.
  • ollama cp —makes a copy of the model.
  • ollama list — lists the downloaded models.
  • ollama run —runs a model. If the model is not already downloaded, it pull and serves it
  • ollama serve — starts the server, to serve the downloaded models.

--

--

No responses yet