Skip to content

Add lcode update: update lcode, and Ollama in Docker - #87

Merged
nasser1941 merged 2 commits into
mainfrom
feat/update
Oct 6, 2026
Merged

nasser1941 merged 2 commits into
mainfrom
feat/update

Conversation

@nasser1941

Copy link
Copy Markdown
Owner

What

lcode update updates lcode, and Ollama when it runs in Docker. --check only shows versions, -y doesn't ask, and lcode update lcode|ollama does one of them.

  • lcode updates the way it was installed. The install is detected from sys.prefix and direct_url.json:
    • uv tool upgrade lcode-cli, pipx upgrade lcode-cli, brew upgrade nasser1941/tap/lcode, or pip install --upgrade;
    • with uvx, a hint;
    • for an editable git checkout, git pull --ff-only (on main/master without local changes), reinstalling the uv tool environment if pyproject.toml changed.
  • Ollama in Docker:
    • The version: the newest release comes from Docker Hub's tag list, never a local latest tag, which can be months old. Only exact X.Y.Z tags count (no -rc), and a ROCm image stays on -rocm.
    • The image: lcode pulls the version tag, e.g. ollama/ollama:0.35.1, so docker ps shows the version.
    • The container is the one publishing the port of ollama_host.
    • Docker Compose (found from the container's compose labels): lcode changes the service's image: line in its compose file and runs docker compose -p <project> -f <files> up -d --no-deps <service>.
      • Only the image value changes; comments and quoting stay.
      • An image set from a variable gets a message instead of an edit.
      • If compose up fails, the file is put back and compose up runs again.
    • Other containers are recreated from docker inspect: name, restart policy, ports, volumes and binds, environment (only what was set beyond the image's), GPUs, devices, runtime, network with aliases, extra hosts, labels, and any changed command.
      • The old container is stopped and renamed as a backup, and removed once the new one answers with the new version.
      • If the new one doesn't, it's removed and the old one is restarted.
    • After the update: if the previous image isn't used any more, lcode prints how to remove it.
  • Ollama outside Docker gets the command that updates it (the Linux install script, brew upgrade ollama), which lcode doesn't run itself.
  • Docs: an "Updating" section in the installation guide, and lcode update in the usage guide.

Tests

  • tests/test_update.py (12 tests) covers:
    • Docker Hub tag selection (release candidates, latest, ROCm, paging);
    • install detection;
    • compose file edits (comments, quotes, variables, build-only services);
    • the recreated docker run arguments;
    • both update paths, with rollback;
    • --check and no terminal changing nothing;
    • up to date; Ollama outside Docker; uv tool upgrade;
    • pulling a real git checkout.
  • Real runs, all on throwaway containers:
    • --check on a Compose-managed Ollama 0.32.15 on ollama/ollama:latest: the newest on Docker Hub is 0.35.1, and the plan names the compose file, service and image.
    • lcode update ollama -y on a throwaway Compose project: pulled ollama/ollama:0.35.1 and changed the compose file's image line, keeping its comment. docker compose up recreated the container on 0.35.1 with its environment and restart policy, and docker ps shows ollama/ollama:0.35.1.
    • The same on a plain docker run container: recreated with the same name, restart policy, port, volume and environment; the backup was removed.
    • Running it again: "up to date".

🤖 Generated with Claude Code

nasser1941 and others added 2 commits October 6, 2026 14:11
lcode updates itself the way it was installed: uv tool, pipx,
Homebrew, pip, or git pull for a checkout (reinstalling the editable
environment when the dependencies changed).

Ollama in a Docker container is updated to the newest release on
Docker Hub (looked up there, since a local latest tag can be months
old; release candidates skipped; ROCm stays ROCm), pulled by its
version tag so docker ps shows the version. A Compose-managed container
gets the new tag in its compose file and docker compose up -d for its
service, with the file put back if that fails. Any other container is
recreated with the same name, ports, volumes, environment, GPUs,
network and restart policy, and the old one comes back if the new one
doesn't answer with the new version. Ollama outside Docker gets the
command that updates it. --check only shows versions; -y doesn't ask.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nasser1941
nasser1941 merged commit 2f4501a into main Oct 6, 2026
12 checks passed
@nasser1941
nasser1941 deleted the feat/update branch October 6, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant