0

I've been trying to launch a containerized mongoDB instance using docker-compose onto ECS w/ Fargate, here is my docker compose configuration:

mongo:
 image: mongo:latest
 restart: always
 environment:
  MONGO_INITDB_USERNAME: root
  MONGO_INITDB_DATABASE: db-name
 volumes:
  - ./migration/init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
 ports:
  - "27017:27017"

Using docker compose version : 3

I'm getting the following error: FATA[0000] ClientException: Fargate compatible task definitions do not support sourcePath

Any ideas on what I'm doing wrong?

Searanox
  • 51
  • 4
  • 1
    `sourcePath` is not supported in `FARGATE` mode since that would require access to the host instance. Take a look at this [post](https://stackoverflow.com/a/53820665/7934282). – zoot Dec 29 '21 at 22:11
  • I see, just to fully clarify this for me, where in my definition am I using `sourcePath`? Is it when I define the use of `volumes`? I'm guessing based on the linked post, my solution is simply to not define `volumes`. – Searanox Dec 30 '21 at 01:51

1 Answers1

1

You can't mount a local file/folder (.migration/init.js) to a task in the cloud. I am not familiar with Mongo so I am not 100% sure what that file does but the easiest way to solve this would be to create a new docker image FROM mongo where the only line would be a ADD to add the init.js file where you need it inside the container (/docker-entrypoint-initdb.d/mongo-init.js ?). The "even easier" way to solve this would be to eliminate the volume directive in the compose (but I don't know what the ramifications of doing so would be for the mongo container you need to run).

mreferre
  • 5,464
  • 3
  • 22
  • 29