简体   繁体   中英

Unable to Connect to Apache Docker Container


I have a server running Apache on port 80 (not in Docker). I would like to create a Docker instance that is also running Apache listening on port 2000 on the host. I have run the following commands to create a Debian Docker instance, forward the traffic, and install Apache on the instance.

docker run --name WebServer -p 2000:80 -t -i debian:latest /bin/bash
apt-get update && apt-get install apache2

After all of this completes, I have verified the port is open on the host (with an Nmap scan). Attempts to connect to 127.0.0.1:2000 are all reset and not actually forwarded to the Docker connection.

What am I missing?

You could use an ' official ' Apache image, my guess would be that you have installed apache2 but nothing more...you haven't started the service or anything like that.

You will have to start the service and maybe just create a 'default' vhost inside the running container and also might be worth checking the port if it is truly open.

Moreover, I would try to add the IP inside my hosts file from the machine I want to check and see the result I am getting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM