Files
estel_docs/content/blog/1.技术栈/993.Docker 里配置hosts.md
estel be69a51bb2
Some checks failed
CI / lint (push) Has been cancelled
CI / typecheck (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
改回项目内获取md文档
2025-08-08 12:15:35 +08:00

639 B
Raw Blame History

title, description, date, img, navigation
title description date img navigation
Docker 里配置hosts 在Docker里配置hosts 2025-06-24 https://lijue-me.oss-cn-chengdu.aliyuncs.com/20250621163604646.png
icon
simple-icons:docker

启动容器时加上“—add-host”参数

docker run 
  --add-host='lijue.me:127.0.0.1' 
  --add-host='www.lijue.me:192.168.1.1' 
  --name hello-docker 
  -it reg.lijue.me/public/hello-docker:latest

通过docker-compose配置extra_hosts属性

1. `version: '3'`
2. `services:`
3. `web:`
4. `image: hello-docker:latest`
5. `extra_hosts:`
6. `- 'www.lijue.me:192.168.1.1'`
7. `- 'lijue.me:127.0.0.1'`