Search code examples
amazon-web-servicesdockeramazon-ec2docker-swarm

how to make ebs volume usable by docker stack


I'm building a multi-tier env in AWS using ansible and Docker (running in Swarm). I have one master and 2 worker nodes. I'm using Docker stack to create services in the swarm using the following command:

docker stack deploy -c myStack.yml myTest

I have 2 questions:

  1. my first question is all my nodes keeps running out of space because Docker is using only ec2's root volume. How can I instruct Docker to create services in EBS volume instead?
  2. is it possible to only create services in workers nodes only and not create any services in manager? can I use the swarm manager for managing the nodes only?

Thanks in advance


Solution

  • Let's start with your second questions, since it is easier.

    You can add label to your nodes, and then use constraint when you create your service (stack is the same). e.g

    docker node update --label-add "role=worker" .... # on all your worker nodes
    docker service create --constraint "node.labels.role==worker" ...
    

    For your first question, you need data persistent. There are some solutions.

    Flocker is a large solution. It has more support, more options and more secure. It is also much difficult to configure.

    Blocker is the one I current using. It have to be install on every node, and I can confirm it is working and working very well. Syntax is like,

    docker service create --mount type=volume,target=/data,source=vol-08a1211f22864700c,volume-driver=blocker ....
    

    I hope this is enough info for you to start your research.