Reputation: 133
I am new to scripting and require some assistance. I am building docker container using YML file. I have YML code written to automate my web server (docker-compose.yml) and database server(docker-compose-mongo.yml).
Now I want to build a bash script that will call for both the yml files and run together.
I was wondering what commands do I need to type within my shell script to call for these two yml files and run them together. I initially just used
#!/bin/bash
run docker-compose.yml
But the above code didn't work.
Ps. below is my yml file for the web server
version: "3"
services:
web:
image: nginx:latest
deploy:
replicas: 5
resources:
limits:
cpus: "0.2"
memory: 330M
restart_policy:
condition: on-failure
ports:
- "80:80"
# networks:
# - webnet
# networks:
# webnet:
Upvotes: 13
Views: 26265
Reputation: 61
You can have multiple yml files on the same command:
docker-compose -f docker-compose.yml -f docker-compose-mongo.yml up -d
Upvotes: 6
Reputation: 36793
You can call them separately:
#!/bin/bash
docker-compose -f docker-compose.yml up -d
docker-compose -f docker-compose-mongo.yml up -d
Or combine both nginx
and mongo
services in the same docker-compose.yml
.
Upvotes: 17