Dockerize Phoenix Application并使用虚拟主机

时间:2017-07-22 13:49:07

标签: docker docker-compose phoenix-framework

我尝试使用Docker设置环境来开发Phoenix应用程序。

Unitil这一点一切都很棒,除了 VIRTUAL_HOST 部分,我想通过访问app.dev而不是localhost:4000来访问我的应用。

我正在使用这个docker-compose.yml文件:

version: '2'

services:

  proxy:
    image: jwilder/nginx-proxy
    ports:
      - 80:80

  postgres:
    image: postgres:latest
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=root

  web:
    build: .
    command: mix phx.server
    volumes:
      - .:/app
    ports:
      - 4000:4000
    depends_on:
      - postgres
    environment:
      - MIX_ENV=dev
      - VIRTUAL_HOST=app.dev
      - VIRTUAL_PORT=4000
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=root
    links:
      - postgres

当我尝试访问app.dev时,我无法访问网站。

编辑#1 对于使用VIRTUAL_HOST,我真的需要反向代理吗?或者简单的dns或者什么就足够了?

编辑#2 好吧,这很奇怪,当我卷曲app.dev我得到html内容,但我无法从浏览器访问它(app.dev)。

1 个答案:

答案 0 :(得分:0)

您不需要nginx,只需将app.dev添加到/etc/hosts文件中。

127.0.0.1 app.dev