简体   繁体   中英

Running docker container at specific URL(s)

Just started implementing docker containers, I'm not sure if it is possible or not yet. Is it possible to publish a docker container based on URL or at specific host header? For example, two containers running at port 192.168.1.2 and port 80 but the first container has website abc.com and the second container has website xyz.com.

Can we use some reverse proxy server eg NGINX (or any other that you suggest) to direct web request to respective docker container?

不,您不能有“两个在IP 192.168.1.2和端口80上运行的容器”,但是可以在IP 192.168.1.2和端口80上运行反向代理,并路由到在不同IP +端口上运行的容器。

Yes, you could do that, you can run a nginx container (or in the host) and it will redirect the content to the right container using the requested server name.

You can map the nginx 80 port in the nginx container to the host and link the others containers to it and then configurate nginx to do the proxy.

Here is a post about how to do it:

http://www.yannmoisan.com/docker.html

If you want to generate nginx configuration dynamically when you start/stop docker containers, you can consider using jwilder/nginx-proxy project. This will give you more flexibility when deciding your domains.

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