2

I have Amazon ECS cluster with EC2 Launch type.

I try to run docker (Linux) container with 25 and 587 port mapping.

Dockerfile is very simple:

FROM microsoft/dotnet:2.0-runtime AS base
WORKDIR /app

FROM microsoft/dotnet:2.0-sdk AS build
WORKDIR /src
COPY *.sln ./
COPY MailTool.Smtp/MailTool.Smtp.csproj MailTool.Smtp/
RUN dotnet restore
COPY . .
WORKDIR /src/MailTool.Smtp
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
EXPOSE 25
EXPOSE 587
ENTRYPOINT ["dotnet", "MailTool.Smtp.dll"]

I have used default setting for my Task Definition.

Task Definition Network Mode is Bridge.

I have mapped ports as depicted on a screenshot: enter image description here

When I have started new task I have the error:

Status reason   CannotStartContainerError: API error (500): driver failed programming external connectivity on endpoint ecs-1-8-1-febb999cf990b2f53700 (646613a2e4c7ae1f0c8e82a2100d468eba09c7dbd64caddde3d14901d14a775c): Error starting userland proxy: listen tcp 0.0.0.0:25

I have the error only on Linux type container. If I use Windows type container then all works fine.

If I change mappings 125 (host port) -> 25 (container port) then task works fine also.

As I understand port 25 for Linux is unavailable...

How can I use port 25 on Amazon ECS EC2 instance for Linux docker containers?

Alexander I.
  • 2,380
  • 3
  • 17
  • 42
  • 1
    You must have launched a `Amazon ECS-optimized AMI`? Just check if any SMTP service is running on it, if so disable and don't start it by default and the port should become available – Tarun Lalwani Apr 09 '18 at 13:31
  • @TarunLalwani I use [AWS Toolkit](https://aws.amazon.com/visualstudio/) for deploy docker containers to Amazon. So my EC2 instance was created automatically. As I understand the instance was created **without** key pair (PEM file). As described in the [documentation](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/instance-connect.html) I have no way to connect to my EC2 instance. – Alexander I. Apr 09 '18 at 14:06
  • My main goal create new clusters and instances automatically without any additional actions. – Alexander I. Apr 09 '18 at 14:07
  • 1
    I think you may have to customize an AMI and create your own and specify the same in AWS toolkit. I have not used the toolkit, but I assume that should be possible – Tarun Lalwani Apr 09 '18 at 18:17

0 Answers0