Copying a file in S3 o ECS Container

0

How do we copy the file in S3 bucket to a particular location inECS Container ? (eg:/usr/local/tomcat/webapps/root/js). I am downloading the image from ECR and creating a container out of it. But I need to copy the custom config-local.js to a particular location in ECS. I am trying to do it via environment command. But it throwing errors. Please help me as I could not find much information for the same in documentation .

2 Answers
0

Have you tried using volumes as mentioned under the Volumes section of this document from docker - https://docs.docker.com/cloud/ecs-integration/

Also look at this - https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html

profile pictureAWS
EXPERT
answered a year ago
  • I have tried adding my file to be copied into a folder in efs and I was able to attach it to a container.But that is not what I am looking for. I want to copy a particular file onto a specific destination inside the container(/usr/local/tomcat/webapps/root/js). Copying to efs and attaching the volume did not solve my problem.Appreciate your response. Thanks in advance!!

0

Hello there.

I would recommend having a docker volume that you can declare very easily if you use docker-compose and have a sidecar that will deal with downloading/creating configuration files for you in this/these docker volume(s). Especially if you do not need the files to be shared across different containers, which would require you to use NFS/AWS EFS.

I have written a sidecar container that can do all of this for you, which you can get from here

I have numerous examples of using it that can be found in labs (GitHub)

The "instructions" on files to download / generate files using it in the docs as well. The configuration itself can be stored in either of these. I usually like to store it base64 encoded in SSM, but if the file gets too large, you can use S3 instead.

To simplify the deployment of your service with these two, I'd recommend using ECS Compose-X which will take care of your volumes configuration, IAM permissions, and access to S3, etc.

This might be one of the simplest examples I have to demonstrate both.

Hope this helps.

profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions