docker - Docker上的UCP和HTTP服务器共存

标签 docker nginx docker-ucp

我有一个使用IP 172.10.100.17在主机上运行的Docker EE。我已经使用默认参数安装了UCP,并且还部署了nginx容器,其主机端口443映射到容器上的443。

docker run -it --rm --name ucp -v /var/run/docker.sock:/var/run/docker.sock docker/ucp install --host-address 172.10.100.17 --interactive  
docker run -it -d --name ngx -p 80:80 -p 443:443 nginx
  • UCP和Nginx是否可以在以下位置共存?
    https://172.10.100.17
  • 当我的主要目标是让Nginx / apache托管在主机IP上时,部署UCP的最佳实践是什么?
  • 是否建议为nginx容器/服务设置静态IP?

  • (注意:在nginx上启用了https)

    最佳答案

    The key is in the -p parameter, which handles port mapping. The first port listed is on the host, and the second is in the container.因此,-p 80:80意味着将主机上的端口80映射到容器中的端口80。

    让我们将其扩展到Nginx。我假设您想同时使用HTTPS和UCP和Nginx。主机上每个端口只能监听一个应用程序。因此,如果两个容器都暴露了端口443,则可以使一个容器在主机上使用端口443(-p 443:443),而另一个容器使用其他端口(-p 4443:443)。然后,即使两个容器都暴露了端口443,您也将分别在主机的端口443和4443上访问它们-Docker正在进行端口转发。

    您可能正在询问如何使用Nginx作为反向代理在单个端口上运行两个容器。尽管更复杂,但这也是可能的。

    关于docker - Docker上的UCP和HTTP服务器共存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61692821/

    相关文章:

    ssl - 带有外部证书的 Docker Datacenter : Error x509 certificate signed by unknown authority UCP 2. 0.0 和 DTR 2.1.0

    docker - 如何从Docker UCP API获取单个堆栈

    caching - 如何仅在 NGINX 中的 index.html 页面上设置不缓存

    node.js - nginx通过docker主机映射路由,对于每个路由,调用不同的容器

    docker - 如何将日志从 jwilder/nginx-proxy docker 镜像发送到 logstash?

    mysql - Spring Boot MySQL Docker Caused by : java.net.ConnectException: Connection refused(连接被拒绝)

    nginx - 服务器域返回 502 Bad Gateway - Nginx

    java - 基于 java 的应用程序的 Docker 镜像生命周期

    python - 基于诗人 tensorflow 的图像分类器再训练期间运行retrain.py时出错