You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从Docker容器访问WAMP虚拟主机地址(如http://ebwp.test)?

Access WAMP Virtual Host http://ebwp.test from a Docker Container

Got it, let's get your Docker container talking to your WAMP virtual host http://ebwp.test — here's how to make that happen smoothly:

Step 1: Confirm Local Setup First

First, double-check that your local machine's hosts file has this entry (WAMP usually adds this automatically when you create a virtual host, but it's worth verifying):

127.0.0.1 ebwp.test

Also, make sure your WAMP Apache config isn't blocking Docker access. If you see Require local in the <Directory> block of your ebwp.test virtual host config, update it to allow Docker's network range (or open it temporarily for testing):

# Option 1: Open access for testing (not ideal for production)
Require all granted

# Option 2: More secure — allow only local and Docker subnets
Require ip 127.0.0.1 172.17.0.0/16 192.168.0.0/16

Restart WAMP Apache after making this change.

Step 2: Map the Virtual Host to Your Host in Docker

You have two solid options here depending on your needs:

Option A: Temporary Fix (Per Container)

When starting your Docker container, use the --add-host flag to map ebwp.test to your host machine's gateway IP. Docker's built-in host-gateway variable handles this automatically, so no need to hardcode IPs:

docker run --add-host ebwp.test:host-gateway your-image-name

This works right away, but you'll need to include this flag every time you start the container.

Option B: Permanent Fix (All Containers)

If you want every new Docker container to resolve ebwp.test to your host automatically, edit Docker's daemon config:

  1. Find the daemon.json file:
    • Windows: C:\ProgramData\Docker\config\daemon.json
    • macOS: ~/.docker/daemon.json
    • Linux: /etc/docker/daemon.json
  2. Create the file if it doesn't exist, then add this content:
    {
      "extra_hosts": ["ebwp.test:host-gateway"]
    }
    
  3. Restart Docker to apply the changes.

Step 3: Test the Connection

Fire up your container, then run a quick test command like:

curl http://ebwp.test

Or if your container has a browser, navigate to http://ebwp.test — you should see your WAMP virtual host site load up successfully!

内容的提问来源于stack exchange,提问作者Lakshmanan Here

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 07:37:39