Skip to content

Instantly share code, notes, and snippets.

@izuolan
Last active February 19, 2017 16:57
Show Gist options
  • Save izuolan/a23667f437433215e1c2 to your computer and use it in GitHub Desktop.
Save izuolan/a23667f437433215e1c2 to your computer and use it in GitHub Desktop.
docker的nginx反向代理

jwilder/nginx-proxy

启动nginx反向代理:

docker run --name nginx -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock -t --restart=always jwilder/nginx-proxy

再启动其他容器,如:

docker run -e VIRTUAL_HOST=yourdomain.com -d tutum/apache-php

nginx的容器会监听其他容器的启动,并根据VIRTUAL_HOST设置域名。

这样可以通过yourdomain.com访问刚才启动的容器中的网站了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment