简体   繁体   中英

Can't Docker host more than one webserver?

Reading this I get the impression that a Docker container can not get a dhcp address or get a dns name.

Question

Does that mean that I can't host two or more webservers which both needs to listen to port 80?

Or even one webserver with a domain name?

Short: Yes you can.

You can run as many webserver as you want and expose them with -p 80 . The webserver inside docker will listen on 80 and docker will nat it to port 49150+.

You can also tell docker to actually listen on the 'real' port 80 with -p 0.0.0.0:80:80 , but then you will be able to start only one. It is very common to start a reverse proxy like this and have it route to other containers via vhost for instance.

You can also run multiple webserver on the 'real' port 80 if you have multiple interfaces with -p <ip interfaceN>:80:80

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