【发布时间】:2015-05-04 15:14:36
【问题描述】:
我正在尝试使用 nginx 和 Ruby 应用程序设置一个简单的反向代理,但我也想在 Docker 容器中设置它。
我已经达到了可以从 Docker 内部运行 Ruby 应用程序并从主机(我的 Mac OS X 使用 Boot2Docker)访问正在运行的服务的地步。但是我现在一直在尝试实现 nginx 部分,因为我以前没有使用过它,而且似乎大多数关于该主题的文章/教程/示例都使用 Rails(而不是简单的 Sinatra/Rack 应用程序)并且还利用套接字 - 据我所知,我不需要。
我也在使用 Docker Compose。
完整的目录结构如下:
├── docker-compose.yml
├── front-end
│ ├── Dockerfile
│ ├── Gemfile
│ ├── app.rb
│ ├── config.ru
├── proxy
│ ├── Dockerfile
│ ├── nginx.conf
│ └── public
│ ├── 500.html
│ ├── index.html
要查看这些文件的内容,请参考以下要点:
https://gist.github.com/Integralist/5cfd5c884b0f2c0c5d11
但是当我运行docker-compose up -d 时,我收到以下错误:
Creating clientcertauth_frontend_1...
Pulling image ./front-end:latest...
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 31, in main
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 27, in dispatch
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 59, in perform_command
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 445, in up
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.project", line 184, in up
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.service", line 259, in recreate_containers
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/compose.service", line 242, in create_container
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/docker.client", line 824, in pull
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/docker.auth.auth", line 67, in resolve_repository_name
File "/Users/ben/fig/build/docker-compose/out00-PYZ.pyz/docker.auth.auth", line 46, in expand_registry_url
docker.errors.DockerException: HTTPS endpoint unresponsive and insecure mode isn't enabled.
我不确定是什么导致了这个错误(谷歌搜索返回https://github.com/docker/compose/issues/563,但据我所知,这似乎是一个单独的问题?)。
如果我能克服这个错误,我也不完全确定 nginx.conf 的设置是否正确。 nginx 的配置看起来应该正确地执行反向代理(例如,使用 frontend 作为上游应用程序服务器,应该然后解析为前端容器的 docker ip 地址 -> 为你会看到我已经将两个容器链接在一起,所以我希望前端应用程序被设置为代理容器的 /etc/hosts 内的别名。
有人知道我可能会错过什么吗?
谢谢。
【问题讨论】:
标签: ruby nginx docker docker-compose