简体   繁体   中英

How to pass docker-compose files to 'docker stack deploy' dynamically?

I can run the following to launch multiple compose files:

docker stack deploy -c docker-compose.yml -c docker-compose.test.yml

I'm using this inside a gitlab-ci pipeline:

deploy:
  script:
    - ssh user@$server "docker stack deploy -c docker-compose.yml -c docker-compose.test.yml appname"
    

Problem: I'd like to pass the docker-compose files dynamically to a gitlab-ci script:

ssh user@$server "docker stack deploy $ARRAY_OF_DOCKER_COMPOSE_FILES appname"

Question: is that possible somehow for swarm mode?

The only solution I could find was to create an intermediate docker-compose file as follows:

docker-compose -f docker-compose.yml -f docker-compose.test.yml config > docker-compose.stack.yml

And then deploy it with: docker stack deploy -c docker-compose.stack.yml

Not the solution that I was looking for, but at least it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM