mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00

# Aider chat conversation: USER: when i run `curl http://127.0.0.1:11434` inside the container, it "Couldn't connect to server". i want it to connect to the server running on the host computer on that port. the host is a mac. ASSISTANT: To allow the Docker container to connect to the host machine on macOS, you can use the special DNS name `host.docker.internal` which resolves to the internal IP address used by the host. This is a feature provided by Docker for Mac to facilitate such connections. Here's the diff to update the `docker.sh` script to include the `--add-host` flag, which adds an entry to the container's `/etc/hosts` file: ```diff --- benchmark/docker.sh +++ benchmark/docker.sh @@ ... @@ docker run \ -it --rm \ -v `pwd`:/aider \ -v `pwd`/tmp.benchmarks/.:/benchmarks \ -e OPENAI_API_KEY=$OPENAI_API_KEY \ -e HISTFILE=/aider/.bash_history \ -e AIDER_DOCKER=1 \ -e AIDER_BENCHMARK_DIR=/benchmarks \ + --add-host=host.docker.internal:host-gateway \ --net=host \ -p 11434:11434 \ aider-benchmark \ bash ``` With this change, when you run `curl http://host.docker.internal:11434` inside the container, it should connect to the server running on the host computer on that port.
15 lines
407 B
Bash
Executable file
15 lines
407 B
Bash
Executable file
#!/bin/bash
|
|
|
|
docker run \
|
|
-it --rm \
|
|
-v `pwd`:/aider \
|
|
-v `pwd`/tmp.benchmarks/.:/benchmarks \
|
|
-e OPENAI_API_KEY=$OPENAI_API_KEY \
|
|
-e HISTFILE=/aider/.bash_history \
|
|
-e AIDER_DOCKER=1 \
|
|
-e AIDER_BENCHMARK_DIR=/benchmarks \
|
|
--add-host=host.docker.internal:host-gateway \
|
|
--net=host \
|
|
-p 11434:11434 \
|
|
aider-benchmark \
|
|
bash
|