Search code examples
dockerdockerfileamazon-ecsosrm

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


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!


Solution

  • 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