Skip to content

Conversation

@ssiweifnag
Copy link

修復內容

修復 #5558:--add-host 範例無法正常運作的問題

問題

python3 HTTP 伺服器佔用前景,導致用戶無法在同樣的終端機執行 docker run 命令。

解決方案

  1. 在 python3 命令後加入 & 讓它在背景執行
  2. 添加 kill %1 來停止 HTTP 伺服器

修改檔案

  • docs/reference/commandline/container_run.md

修改內容

- $ python3 -m http.server 8000
+ $ python3 -m http.server 8000 &
  Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
  $ docker run \
    --add-host host.docker.internal=host-gateway \
    curlimages/curl -s host.docker.internal:8000/hello
  hello from host!
+ $ kill %1  # Stop the HTTP server

關聯 Issue

Fixes #5558

@ssiweifnag ssiweifnag requested review from a team and thaJeztah as code owners February 5, 2026 03:11
Add '&' to run python3 in background so users can execute
the docker run command in the same terminal session.
Add 'kill %1' to stop the HTTP server after the example.

Fixes docker#5558
@ssiweifnag ssiweifnag force-pushed the fix/add-host-example branch from d2beba0 to 53b2ced Compare February 5, 2026 08:12
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.

--add-host example doesn't work as shown

1 participant