Search code examples
amazon-web-servicesdockeramazon-ecs

Run docker image on amazon ecs


I have a docker image which runs with this command

docker run -it -p 8118:8118 -p 9050:9050 -d dperson/torproxy

It requires a port as an argument.

What I tried?

I pushed this image to ECR repo, created task related to this image. After I created service with network-load-balancer. But the server is not responding when I try to GET DNS name of network-load-balancer.

I think this is because I didn't configure the port for the container. How can I do this?


Solution

  • Port Mappings are part of the Task Definition > Container Definitions.

    This can be done through the UI Add Container or using the CLI / SDK RegisterTaskDefinition

    {
       "containerDefinitions": [ 
          { 
             ...
             "portMappings": [ 
                { 
                   "containerPort": number,
                   "hostPort": number,
                   "protocol": "string"
                }
             ],
             ...
          }
       ]      
    }