Town help you run multi-container application in Docker. Defining a single cluster configuration file. It is simple, just like Docker Compose tool. However, it has several advantages:
- partial cluster update - in case images were updated it will restart only the dependant part of the cluster
- dynamic configuration support - IP address or number of the scale (i.e., creating number of images for this instance) can be passed
Town is small and simple tool help small startups run they infrastructure very quickly.
Download the latest release:
- Mac x86
- Mac x64
- Linux x86
- Linux x64
- Linux ARM
- Freebsd x86
- Freebsd x64
- Freebsd ARM
- Windows x86
- Windows x64
Configuration files must be in current directoy or /etc/town/ Configuration file describe containers, container relationship itself and scale of the cluster.
demo.yaml
application:
cluster:
www: 1
redis: 1
nginx: 1
docker:
hosts:
- unix:///var/run/docker.sock
redis:
image: redis
environment:
- REDIS_PASS=secretpassword
www:
image: node
command: ${SCALE_INDEX}
links:
- redis
volumes:
- /var/log/www-${SCALE_INDEX}/log/:/var/log/nodejs
nginx:
image: nginx
privileged: true
environment:
- WWW_HOSTS=${WWW_HOSTS}
ports:
- "80:80"
links:
- node
volumes:
- /opt/public:/opt/static/
To Run town simple execute command:
town run
The configuration file /etc/town/town.yaml has list of containers names. The application item is reserved keyword and used for cluster definition. Here you can define how many instances of containers town needs to create.
Each container must have image key. The keys command, environment and volume can containe dynamic variables:
- ${SCALE_INDEX} - Index of given container. Start from 1.
- ${(container_name)_HOSTS} - Comma separated list of hosts.
Docker image definition.
Override default command of the container.
Link to container in another service. Link is the name of other containers and will be dynamicly added depends of the container scale.
Expose ports.
List of environments variables passed to container.
Mount paths as volumes.
Run containers. If the container is already running nothing will happend. But if the conatiner has new image, town will catch it and restart this container and all refer to it.
Restart all cluster. This operation will gracefully shutdown, remove containers and start from sratch whole cluster.
Stop and remove all containers.
Kiril Menshikov - https://twitter.com/kiril
Arturs Licis - https://twitter.com/arturs_li
Code and documentation copyright 2015 Lookify.co Code released under the Apache 2.0 license.