Created
April 17, 2026 06:42
-
-
Save karthiks/d5d94270ec5b2d2782232aafb8a95500 to your computer and use it in GitHub Desktop.
Reference implementation to showcase connecting to Ollama service on Windows host from Docker container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:20-slim | |
| # 1. Install essential system tools (curl for testing, git for Claude) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| bash curl git vim sudo ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 2. Install Claude Code globally via npm | |
| # Using npm here ensures a non-interactive, reliable build. | |
| # Warning: Installing CC via npm is bloat. Should install natively via bash script for lean installation. | |
| RUN npm install -g @anthropic-ai/claude-code@2.1.19 | |
| # 3. Environment Configuration for Ollama | |
| # ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are the mandatory environment variables to be set to get CC working | |
| ENV ANTHROPIC_BASE_URL="http://host.docker.internal:11434/v1" \ | |
| ANTHROPIC_AUTH_TOKEN="ollama" \ | |
| ANTHROPIC_API_KEY="sk-no-key-required" \ | |
| TERM=xterm-256color | |
| WORKDIR /workspace | |
| # 4. Create a non-root user for security | |
| # Warning: Better to re-use existing user with USER_ID=1000 | |
| RUN useradd -m developer && chown -R developer /workspace | |
| USER developer | |
| # Set the default command to bash so you can run your curl test first | |
| ENTRYPOINT ["bash"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment