How do I define a start command for an app using Docker images?

Docker images do not use the Procfile to define process commands.

If the image is built locally and pushed to the Heroku Image Registry the start command should be defined in the Dockerfile as CMD.

To use the same image for multiple processes (eg web and worker) define a custom script as the startup command:

# Dockerfile
...
CMD start.sh

Then the script can inspect the $DYNO environment variable to use the correct command:

# start.sh
if [[ $DYNO == "web"* ]]; then
  rails server -p $PORT
elif  [[ $DYNO == "worker"* ]]; then
  sidekiq -q default
fi

If the application is using heroku.yml (image is built on Heroku) the start command can be defined in the run section of heroku.yml*
https://devcenter.heroku.com/articles/build-docker-images-heroku-yml#run-defining-the-processes-to-run

*Apps in Private Spaces using heroku.yml must use the 1st, CMD approach. The run command from heroku.yml is not recognized in Spaces:
https://help.heroku.com/RNIC7H18/why-my-private-spaces-app-on-container-registry-runtime-ignores-heroku-yml

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support