Stackfiles for your service

Estimated reading time: 2 minutes

What are stack files?

A stack is a logical grouping of related services that are usually deployed together and require each other to work as intended. If you are familiar with fig or Docker Compose then you should feel right at home with stacks. You can learn more about stacks here.

Stack files are YAML files, and you can learn more about the available syntax here. You can also interact with stacks using the stack commands in our API.

Service definitions in the stack file

The services that you created in this tutorial form a stack with three services: the load-balancer, the web application, and the redis cache.

Look at the file called docker-cloud.yml in your quickstart to see the stack file that defines the three services (lb, web, redis) you created in the previous steps, including all modifications and environment variables.

This is what the docker-cloud.yml file looks like. (If you are using the quickstart-go version, you’ll see quickstart-go instead of quickstart-python.)

  image: dockercloud/haproxy
  autorestart: always
    - web
    - "80:80"
    - global
  image: dockercloud/quickstart-python
  autorestart: always
    - redis
    - NAME=Friendly Users
  deployment_strategy: high_availability
  target_num_containers: 4
  image: redis
  autorestart: always
    - REDIS_PASS=password

You can use this stack file to quickly deploy this cluster of three services to another set of nodes. You can also edit the file to change the configuration.

Run a stack

To create the services in a stack file you use the simple stack up command.

You can run this in the path containing your stackfile (docker-cloud.yml), like so:

$ docker-cloud stack up

Or you can specify the YML file to use and its location:

$ docker-cloud up -f /usr/dockercloud/quickstart-python/docker-cloud.yml

What’s Next?

Next, we’ll do some Data management with Volumes.

Python, service, stack