Docker Community Forums

Share and learn in the Docker community.

Override docker-compose on up


(LEGENDRE) #1

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
app:
  build: .
  command: sh docker/docker-entrypoint.sh
  ports:
    - "3000:#{RAILS_PORT}"

Is it possible to do something similar?

Thx :slight_smile:


(Alexandre) #2

Yes, you will need to use ${VAR_NAME}

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


(LEGENDRE) #3

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