Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
How can I pass the argument to docker-compose.yml using shell file

I have docker-compose.yml as follows:

version: '2'

services:
  eureka-server:
    image: some-dtr-name/some-orgname/some-reponame:some-versionname
    mem_limit: somememory
    environment:
      SPRING_PROFILES_ACTIVE: some-profile
      JAVA_OPTS: -Xms256m -Xmx512m
    ports:
    - "some-port:some-port"
    restart: always
    networks:
    - cloud

networks:
  cloud:
   driver: bridge

I want to pass some-dtr-name,some-orgname,some-reponame,some-versionname,somememory,some-profile,some-profile,some-port as a aurgument to docker-compose file. I am doing this task using shell file.

#!/bin/bash
some-dtr-name="$1"
some-orgname="$2"
some-reponame="$3"
some-versionname="$4"
somememory="$5"
some-profile="$6"
some-profile="$7"
some-port="$8"

docker-compose up

How can I do this task ??

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Docker compose supports the environment variable substitution, using the ${} syntax: https://docs.docker.com/compose/compose-file/#variable-substitution

So if you have the environment variable some_port defined, before you run docker-compose, you can then just refer to it as ${some_port} in your docker-compose file.

ports:
- "${some_port}:${some_port}"

Another thing to note is that the variable names in your sample code contain dashes -, which is not valid in bash

name A word consisting only of alphanumeric characters and underscores, and beginning with an alphabetic character or an underscore. Also referred to as an identifier.

you have to use underscore character _ instead.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!