2

I want to set which profiles use to docker stack deploy. I mean, assume my docker-compose.yml is like this:

version: '3.8' services: admin: image: "${ADMIN_IMAGE}" restart: always profiles: - "admin" api: image: "${API_IMAGE}" restart: always profiles: - "api" redis: image: "${REDIS_IMAGE}" restart: always profiles: - "redis" 

And want to deploy just admin and Redis services. If it was docker-compose, then I had two options: docker compose --profile=admin --profile=redis up -d or COMPOSE_PROFILES=admin,redis docker compose up -d but I want to deploy this as a swarm stack with docker stack deploy --compose-file docker-compose.yml stack_name and I can't. Both options don't work in this situation, although docker docs says swarm supports it, but don't say how.

So my question is:

  • Do docker swarm support profiles?
  • If it is supported, how I use it?
  • Else, how can I deploy a part of compose file?

1 Answer 1

1

It seems profiles are not supported yet in docker swarm. Using the docker stack config command on a docker-compose.yml file with profiles returns an error:

$ docker stack config -c docker-compose.yml services.my_service Additional property profiles is not allowed 

For now the only workaround I figured out is to create different docker-compose.yml files for each profile I have, and docker stack deploy them into the same stack only when needed.

It's not a clean solution I know, just a workaround...

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.