尝试使用docker

时间:2018-05-19 08:32:54

标签: node.js docker nginx docker-compose nginx-reverse-proxy

因此,我尝试按照示例here来执行将处理所有其他容器的nginx代理容器。我已经尝试遵循配置环境变量的格式,以便站点通过nginx-proxy工作。到目前为止,我只是部署了一个站点,如果我使用的是80或443以外的端口。我想知道我可以得到任何帮助,我已经粘贴了下面的两个文件。

Dockerfile

FROM node:carbon                                                                                                      
# Create app directory
WORKDIR ./home/username/website/production

COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]

搬运工-compose.yml

version: "3"                                                                                                          
    services:
        website:
            build: .
            volumes:
                - .:/home/user/website
                - ./home/user/website/node_modules
            ports:
                - "8080:8080"
            expose:
                - 80
            environment:
                VIRTUAL_HOST: domain.com
                LETSENCRYPT_HOST: domain.com
                LETSENCRYPT_EMAIL: domain.com
    networks:
        default:
            external:
                name: nginx-proxy      

我已尝试侦听端口80和443.但是,nginx返回503错误。所以我想知道是否有人可以阐明如何配置它。

1 个答案:

答案 0 :(得分:0)

所以我让它部署了两个独立的容器,一个作为domain.com,另一个作为subdomain.domain.com,同时监听端口80.该网站甚至默认为https,就像nginx处理那样。我没有使用docker-compose.yml文件,而是按照Code trace:的指示而不是使用普通docker的博客重新编写nginx-proxy。之后我使用他们的格式部署如下:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let row = self.sections[indexPath.section].rows[indexPath.row]
    switch row {
        case .Email:
            cell.infoLabel.setTitle(cellInfo.email, for: .normal)
            cell.infoLabel.recipentEmail = cellInfo.email
            cell.infoLabel.addTarget(self, action: #selector(emailPressed(_ :)), for: .touchUpInside)
            cell.imageType.image = UIImage(named: "Email")
    }
}

@objc func emailPressed(_ sender: RecipientButton) {
    guard let email = sender.recipientEmail else { return }
    self.delegate?.dataController(self, recipientEmail: email)
}

这些是在他们的github page上找到的我认为至少在我了解更多关于码头工具本身之前我会避免使用码头工作,但是如果有人能够解释为什么码头工具组合设置没有&# 39;工作,我们将不胜感激。

相关问题