Files
estel_docs/content/blog/1.技术栈/993.Docker 里配置hosts.md
estel 4569d80f03
Some checks failed
CI / lint (push) Has been cancelled
CI / typecheck (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
chore: 更新图片链接域名从lijue-me.oss-cn-chengdu.aliyuncs.com到img.jiwei.xin
2025-09-08 19:52:04 +08:00

618 B
Raw Blame History

title, description, date, img, navigation
title description date img navigation
Docker 里配置hosts 在Docker里配置hosts 2025-06-24 https://img.jiwei.xin/20250621163604646.png
icon
simple-icons:docker

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

docker run
  --add-host='lijue.net:127.0.0.1'
  --add-host='www.lijue.net:192.168.1.1'
  --name hello-docker
  -it reg.lijue.net/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.net:192.168.1.1'`
7. `- 'lijue.net:127.0.0.1'`