Skip to content
Discussion options

You must be logged in to vote

I’m wondering whether there is a mechanism similar to host_db_port:
• when the variable is not set, generate a random host port
• when the variable is set, use the user-defined port

Yes, it's simple:

services:
  redis:
    ports:
      - "${REDIS_HOST_PORT:-}:6379"

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@faytecCD
Comment options

@faytecCD
Comment options

@rfay
Comment options

rfay Dec 11, 2025
Maintainer

Comment options

You must be logged in to vote
1 reply
@faytecCD
Comment options

Answer selected by faytecCD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants