# Prevent scheduling scaled containers on same host

**URL:** <https://forums.suse.com/t/prevent-scheduling-scaled-containers-on-same-host/1115>\
**Category:** Rancher 1.x\
**Created:** [November 28, 2015, 7:25pm UTC](https://forums.suse.com/t/prevent-scheduling-scaled-containers-on-same-host/1115 "2015-11-28T19:25:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![untoldone](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/untoldone/32/580_2.png) [@untoldone](https://forums.suse.com/u/untoldone)\
**Post date:** [November 28, 2015, 7:25pm UTC](https://forums.suse.com/t/prevent-scheduling-scaled-containers-on-same-host/1115/1 "2015-11-28T19:25:54Z")

</div>

Given [http://docs.rancher.com/rancher/concepts/scheduling/](http://docs.rancher.com/rancher/concepts/scheduling/) it appears the default behavior is to prefer (but not require) to not have containers of the same Service scheduled to the same host.

Is there a way to require containers are not scheduled to the same host? In the case that you have volumes based on local paths, it seems important for service containers to not share the same local files in some cases (e.g. databases etc).

---

<div class="post-metadata">

**Author:** ![untoldone](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/untoldone/32/580_2.png) [@untoldone](https://forums.suse.com/u/untoldone)\
**Post date:** [November 28, 2015, 8:12pm UTC](https://forums.suse.com/t/prevent-scheduling-scaled-containers-on-same-host/1115/2 "2015-11-28T20:12:48Z")

</div>

Believe I figured out a way to do this e.g:

docker-compose:

```auto
es4:
  labels:
    es4: 'true'
    io.rancher.scheduler.affinity:container_label_ne: es4=true
  tty: true
  image: elasticsearch
  volumes:
  - /data/es-demo4:/data/es-demo4
  stdin_open: true

```

Note the label `es4=true` and the scheduling requirement that there must not be another container with the label `es4=true`.
