Passing config file from one container to another in ecs ec2 launch type

Viewed 12

I have been struggling with this issue for a while: I want to pass the config file located on Container A app/config-file/nginx/nginx.conf and pass it into etc/nginx/conf.d/default.conf so that the official nginx image that I'm running along side my default container can use my custom config file. I have tried to use bindMounts as shown in the aws docs to do this and even set a start-up dependency but for some reason, I am still not getting the correct config file to populate. It just resorts to the default config that comes with the nginx image. Below is my task definition template showing how I am trying to do this (I created named volumes outside of the task-definition)

  {
    
    "command": [],
    "entrypoint": [
      "uwsgi",
      "--ini",
  
    ],
    "cpu": 250,
    "memoryReservation": 1024,
    "image": "${image_url}",
    "name": "${container_name}",
    "mountPoints": [
      {
        "containerPath": "/app/config-file/nginx",
        "sourceVolume": "nginx-config"
      }
   
    ],
    
   
  },
  
  {
    "name": "${container_name}-nginx",
    "image": "nginx:1.19-alpine",
    "essential": true,
    "dependsOn": [
      {
        "containerName": "${container_name}",
        "condition": "START"
      }
    ],

    
    "mountPoints": [
      {
        "containerPath": "/etc/nginx/conf.d/",
        "sourceVolume": "nginx-config"
      }
    ],
    "cpu": 250,
    "memoryReservation": 250,

    "portMappings": [
      {
        "protocol": "tcp",
        "containerPort": 4000,
        "HostPort" : 0
      }
    ]
  }
]``` 


I do want to mention that I know there are ways to do this by using efs, s3, or by baking the custom config into the nginx image. I would prefer if I did not have to go down those routes though. 
0 Answers
Related