Override docker-compose on up

Hi everyone !

I’m passing a rails project on Docker. Currently, it’s only for development purpose.

I would like to choose the opening port without having to change the docker-compose.yml

For example :

$ docker-compose up rails-port=3001
# Launch the ruby server
  build: .
  command: sh docker/docker-entrypoint.sh
    - "3000:#{RAILS_PORT}"

Is it possible to do something similar?

Thx :slight_smile:

Yes, you will need to use ${VAR_NAME}

This usage is documented. Please refer to the Compose file reference:

Thx aleveille I had seen him on stack overflow but i didn’t understand it correctly.