简体   繁体   English

无法连接到已部署的容器

[英]Unable to connect to a deployed container

I deployed Docker container on AWS EC2 and exposed the port 5001 to the world, however when I try to view it on 18.130.178.90:5001/users I get Unable to connect . 我在AWS EC2上部署了Docker容器并将端口5001暴露给世界,但是当我尝试在18.130.178.90:5001/users上查看它时,我Unable to connect

5001    tcp 0.0.0.0/0   ✔

inbound port 5001 is exposed. 入站端口5001已暴露。 Public IP assigned by AWS IPv4 Public IP 18.130.178.90 由AWS IPv4 Public IP 18.130.178.90分配的IPv4 Public IP 18.130.178.90

What can I try ? 我可以尝试什么?

在此处输入图片说明

Requested screenshot: 要求的屏幕截图:

在此处输入图片说明

Dockerfile: Dockerfile:

FROM python:3.6.9-alpine
LABEL maintainer="mark.alexa@gmail.com"

RUN apk update && apk add --virtual build-deps gcc python-dev musl-dev && \
    apk add postgresql-dev && apk add netcat-openbsd

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt

COPY ./entrypoint.sh /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh

COPY . /usr/src/app

CMD ["/usr/src/app/entrypoint.sh"]

Docker-compose.yml: Docker-compose.yml:

version: '3.7'

services:
  users:
    build:
      context: ./users
      dockerfile: Dockerfile

    ports:
      - 5001:5000
    environment:
      - FLASK_ENV=production
      - APP_SETTINGS=project.config.DevelopmentConfig
      - DATABASE_URL=postgres://postgres:postgres@users-db:5432/users_prod
      - DATABASE_TEST_URL=postgres://postgres:postgres@users-db:5432/users_test
    depends_on:
      - users-db

  users-db:
    build:
      context: './users/project/db'
      dockerfile: Dockerfile
    ports:
      - 5435:5432
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres

I am assuming you have deployed the container using AWS ECS - EC2 options since you are trying to connect to the container, I will assume this is a security group issue for the particular connection you are trying to make with the container. 由于您要尝试连接到容器,因此我假设您已使用AWS ECS-EC2选项部署了该容器,对于要与该容器建立的特定连接,这将是一个安全组问题。 I would check the security groups first. 我将首先检查安全组。 Also, make sure the physical HOST that the docker container is currently running on is mapped to the port of the containers port on 5001. So you should see the physical hosts port connected to the port of the docker container. 此外,请确保将当前正在运行的Docker容器的物理主机映射到5001上的容器端口的端口。因此,您应该看到连接到Docker容器端口的物理主机端口。 Let me know if this helps. 让我知道是否有帮助。

Problem was determined by ssh into the deployed container. 问题是通过SSH进入已部署的容器确定的。 The container was using wrong certificates. 容器使用了错误的证书。 I ran locally docker-machine regenerate-certs testdriven-prod1 then it created new certs which were applied to the deployed container and now I'm able to connect to it. 我在本地运行docker-machine regenerate-certs testdriven-prod1然后创建了新证书,这些证书已应用于已部署的容器,现在我可以连接到它了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM