简体   繁体   中英

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 .

5001    tcp 0.0.0.0/0   ✔

inbound port 5001 is exposed. Public IP assigned by AWS IPv4 Public IP 18.130.178.90

What can I try ?

在此处输入图片说明

Requested screenshot:

在此处输入图片说明

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:

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. 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. Let me know if this helps.

Problem was determined by ssh into the deployed container. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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