Piu130
Piu130

Reputation: 1407

Pass service params to docker-compose up

I have the following docker-compose.yml:

version: '2'
services:
  strongloop:
    image: node:5.11-onbuild
    links:
      - mongodb
  mongodb:
    image: mongo:3.3
    volumes:
      - ./mongo/mongo.conf:/etc/mongo.conf

Now I need to start the mongodb service with the flag -f /etc/mongo.conf and parallel starts the strongloop service and link them. Until now I did this with docker-compose up because I didn't need some flags.

How can I pass this flag to docker-compose up?

Or is there an other command that links the container and where I can pass some params to the specific service?

Edit:

docker-compose up mongodb -f /etc/mongo.conf strongloop returns ERROR: No such service: -f

docker-compose up "mongodb -f /etc/mongo.conf" strongloop returns ERROR: No such service: mongodb -f /etc/mongo.conf

Upvotes: 1

Views: 577

Answers (1)

Nguyen Sy Thanh Son
Nguyen Sy Thanh Son

Reputation: 5376

You should change docker-compose.yml as below:

version: '2'
services:
  strongloop:
    image: node:5.11-onbuild
    links:
      - mongodb
  mongodb:
    image: mongo:3.3
    command: mongod -f /etc/mongo.conf
    volumes:
      - ./mongo/mongo.conf:/etc/mongo.conf

After that, just run:

docker-compose up

Upvotes: 1

Related Questions