AWS ECS Fargate copy local file to container
Asked Answered
F

1

8

there is a simple way to copy files from local host to AWS ECS Fargate container?

Like Docker cp docker cp :/file/path/in/container/file /host/local/path/file ?

I've found some workarounds like:

  • pass through a S3 Bucket (I have to install AWS cli on container and give him credentials inside container...not a beaeutiful thing!)
  • mount an EFS shared folder in EC2 instance (I've to mount EFS folder in instance and upload the file to it from my host...2 steps and shared folder)

Can someone help me please?

Thanks

Fraenum answered 17/9, 2021 at 10:11 Comment(3)
It's serverless technology- you have to expect to take some steps to give the task access to a file and you have exhausted the options already. Your first option would not to my mind be considered out of the ordinary-install the cli in your Dockerfile and have an ECS Task Role with s3 access - that's standard stuff.Urbina
Thanks, maybe in future Amazon will provide this direct access like Docker. S3 approach means that you have to store aws credential (unless with limitate access) and I don't like too much this solution, but if there aren't alternatives...Fraenum
Perhaps it's a language thing but providing a ECS Task role and 'having to store aws credentials' are different things in intent and implication.Urbina
S
0

There's no docker cp for ECS Fargate. For most use-cases and for large files S3 is a good way to transfer files to your container. One can run their ECS task/service with a task role and then with AWS CLI or any AWS SDK you can use those the task role to fetch the object from S3. CLI and most SDKs can use the role within the container out of the box without any configuration.

For one-off small non-binary files that you wouldn't be too scared missing a byte here and there, ECS exec could be used which provides you a shell into your container and then you could paste or pipe your file contents into another file via ECS exec shell.

Shafer answered 30/4 at 21:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.