In elastic beanstalk, how do I run a command before the container is launched?

3.4k views Asked by At

I'm using the a single container docker version of Elastic Beanstalk to deploy a ruby on rails application (my docker is pre-built). The docker image specifies a CMD of "rails server".

I would like to issue "rake db:migrate" just before the "rails server" is run. Is there a way to do it using elastic beanstalk configuration or otherwise?

1

There are 1 answers

4
pkopac On BEST ANSWER

Either you replace the CMD/ENTRYPOINT with a script where you run that inside the running docker container (runs each time you start the docker container), or you add this to .ebextensions/00-my-tasks.config:

container_commands:
  00-my-task:
    command: rake db:migrate

Then it runs in the elastic-beanstalk container/virtual machine, but outside of docker container.