How to write a file to the host in advance and then start the Docker container?

854 Views Asked by At

My task is to deploy a third-party OSRM service on Amazon ECS Fargate.

For OSRM docker at startup, you need to transfer a file containing geodata.

The problem is that Amazon ECS Fargate does not provide access to the host file system and does not provide the ability to attach files and folders during container deployments.

Therefore, I would like to create an intermediate image that, when building, saved the file with geodata, and when starting the container, it would use it when defining volumes.

Thanks!

2

There are 2 best solutions below

0
On BEST ANSWER

The solution turned out to be quite simple.

For this Dockerfile, I created an image on my local machine and hosted it on DockerHub:

FROM osrm/osrm-backend:latest
COPY data /data
ENTRYPOINT ["osrm-routed","--algorithm","mld","/data/andorra-latest.osm.pbf"]

After that, without any settings and volumes, I launched this image in AWS ECS

4
On

As I understand it, Amazon ECS is a plain container orchestrator and does not implement docker swarm, so things like docker configs are off the cards.

However, you should be able to do something like this :-

ID=$(docker create --name my-osrm osrm-base-image)
docker cp ./file.ext $ID:/path/in/container
docker start $ID