Skip to main content

Docker Personal Case Notes

This page is specifically for my own command snippets and scenario records. They may not be suitable for direct copying into other environments, but keeping them here is more appropriate than mixing them into the main tutorials.

Ollama Container Example

Map the container's 11434 port to the host's 8080 and enable GPU:

docker run -d \
--gpus all \
-v ollama:/root/.ollama \
-p 8080:11434 \
--name ollama_new \
ollama/ollama

The key points of this command are:

  • GPU passthrough: --gpus all
  • Data persistence: -v ollama:/root/.ollama
  • Port mapping: -p 8080:11434

Taking a Snapshot After Manual Container Configuration

In some scenarios, I first manually configure the environment inside a container until it works, then temporarily save it as an image:

docker commit ubuntu_llama_factory ubuntu_base:latest
docker save -o ubuntu_base.tar ubuntu_base:latest

Import on another machine:

docker load --input /path/to/your/image.tar

This approach is more of a temporary solution. If this environment needs to be kept long-term, you should return to using a Dockerfile.

Copying Local Files into a Running Container

docker cp /root/llama_factory.zip singularity_llama_factory:/miniconda3/envs

This command is suitable for one-time file delivery, not as a long-term synchronization mechanism.

Re-entering a Container

docker ps
docker exec -it container_id_or_name bash

If the image does not have bash:

docker exec -it container_id_or_name sh

Tools I Typically Install in an Ubuntu Base Environment

apt-get update
apt-get install -y \
vim \
git \
build-essential \
wget \
net-tools \
sudo

In some environments that lean toward compilation or container toolchains, I also add these dependencies:

sudo apt-get update && sudo apt-get install -y \
build-essential \
libssl-dev \
uuid-dev \
libgpgme11-dev \
squashfs-tools \
libseccomp-dev \
wget \
pkg-config \
git \
cryptsetup-bin

Usage Principles for This Page

  • This page allows specific container names, project names, and path names
  • Main pages only keep general solutions
  • If a personal case later becomes a stable pattern, consider moving it back to the main documentation