You can use the environment variable inside docker-compose.
svr: extends: file: docker-compose-base.yml service: base command: npm run prod:deploy ports: - ${CLTPORT}:${PORT} environment: NODE_ENV: production clt: extends: file: docker-compose-base.yml service: base command: npm run prod:deploy:clientside ports: - ${CLTPORT2}:${PORT2} environment: NODE_ENV: production
run docker-compose like:
CLTPORT=8082 PORT=8081 CLTPORT2=8081 PORT2=8082 docker-compose -f docker-compose-prod.yml up
Of course, change the port variables as you need.
source share