2014-01-27 16:03:21 +01:00
---
layout: default
title: fig.yml reference
---
fig.yml reference
=================
Each service defined in `fig.yml` must specify exactly one of `image` or `build` . Other keys are optional, and are analogous to their `docker run` command-line counterparts.
As with `docker run` , options specified in the Dockerfile (e.g. `CMD` , `EXPOSE` , `VOLUME` , `ENV` ) are respected by default - you don't need to specify them again in `fig.yml` .
2014-07-12 18:45:11 +02:00
###image
Tag or partial image ID. Can be local or remote - Fig will attempt to pull if it doesn't exist locally.
```
2014-01-27 16:03:21 +01:00
image: ubuntu
image: orchardup/postgresql
image: a4bc65fd
2014-07-12 18:45:11 +02:00
```
### build
Path to a directory containing a Dockerfile. Fig will build and tag it with a generated name, and use that image thereafter.
2014-01-27 16:03:21 +01:00
2014-07-12 18:45:11 +02:00
```
2014-01-27 16:03:21 +01:00
build: /path/to/build/dir
2014-07-12 18:45:11 +02:00
```
### command
2014-01-27 16:03:21 +01:00
2014-07-12 18:45:11 +02:00
Override the default command.
```
2014-01-27 16:03:21 +01:00
command: bundle exec thin -p 3000
2014-07-12 18:45:11 +02:00
```
2014-08-08 19:59:08 +02:00
< a name = "links" > < / a >
2014-07-12 18:45:11 +02:00
### links
2014-08-08 20:00:10 +02:00
Link to containers in another service. Either specify both the service name and the link alias (`SERVICE:ALIAS`), or just the service name (which will also be used for the alias).
2014-07-12 18:45:11 +02:00
```
2014-01-27 16:03:21 +01:00
links:
- db
2014-03-03 18:58:35 +01:00
- db:database
2014-01-27 16:03:21 +01:00
- redis
2014-07-12 18:45:11 +02:00
```
2014-08-08 19:59:08 +02:00
An entry with the alias' name will be created in `/etc/hosts` inside containers for this service, e.g:
```
2014-08-08 20:00:10 +02:00
172.17.2.186 db
2014-08-08 19:59:08 +02:00
172.17.2.186 database
2014-08-08 20:00:10 +02:00
172.17.2.187 redis
2014-08-08 19:59:08 +02:00
```
Environment variables will also be created - see the [environment variable reference ](env.html ) for details.
2014-07-12 18:45:11 +02:00
### ports
Expose ports. Either specify both ports (`HOST:CONTAINER`), or just the container port (a random host port will be chosen).
2014-01-27 16:03:21 +01:00
2014-07-12 18:45:11 +02:00
**Note:** When mapping ports in the `HOST:CONTAINER` format, you may experience erroneous results when using a container port lower than 60, because YAML will parse numbers in the format `xx:yy` as sexagesimal (base 60). For this reason, we recommend always explicitly specifying your port mappings as strings.
```
2014-01-27 16:03:21 +01:00
ports:
2014-02-20 13:53:43 +01:00
- "3000"
- "8000:8000"
- "49100:22"
2014-07-12 18:38:18 +02:00
- "127.0.0.1:8001:8001"
2014-07-12 18:45:11 +02:00
```
### expose
Expose ports without publishing them to the host machine - they'll only be accessible to linked services. Only the internal port can be specified.
2014-01-27 16:03:21 +01:00
2014-07-12 18:45:11 +02:00
```
2014-03-04 18:59:42 +01:00
expose:
- "3000"
- "8000"
2014-07-12 18:45:11 +02:00
```
2014-03-04 18:59:42 +01:00
2014-07-12 18:45:11 +02:00
### volumes
2014-08-26 04:16:37 +02:00
Mount paths as volumes, optionally specifying a path on the host machine
(`HOST:CONTAINER`), or an access mode (`HOST:CONTAINER:ro`).
2014-07-24 23:16:49 +02:00
2014-07-12 18:45:11 +02:00
```
2014-01-27 16:03:21 +01:00
volumes:
2014-07-12 18:55:11 +02:00
- /var/lib/mysql
2014-01-27 16:03:21 +01:00
- cache/:/tmp/cache
2014-08-26 04:16:37 +02:00
- ~/configs:/etc/configs/:ro
2014-07-12 18:45:11 +02:00
```
### volumes_from
2014-01-27 16:03:21 +01:00
2014-07-12 18:45:11 +02:00
Mount all of the volumes from another service or container.
```
2014-07-11 20:11:54 +02:00
volumes_from:
- service_name
- container_name
2014-07-12 18:45:11 +02:00
```
### environment
2014-07-12 18:55:11 +02:00
Add environment variables. You can use either an array or a dictionary.
Environment variables with only a key are resolved to their values on the machine Fig is running on, which can be helpful for secret or host-specific values.
2014-07-11 20:11:54 +02:00
2014-07-12 18:45:11 +02:00
```
2014-01-27 16:03:21 +01:00
environment:
RACK_ENV: development
2014-07-11 19:07:50 +02:00
SESSION_SECRET:
2014-07-12 18:55:11 +02:00
environment:
- RACK_ENV=development
- SESSION_SECRET
2014-01-27 16:03:21 +01:00
```
2014-09-12 05:57:23 +02:00
### env_file
Add environment variables from a file. Can be a single value or a list.
Environment variables specified in `environment` override these values.
```
env_file:
- .env
```
```
RACK_ENV: development
```
2014-07-12 18:45:11 +02:00
### net
Networking mode. Use the same values as the docker client `--net` parameter.
```
2014-07-12 18:55:11 +02:00
net: "bridge"
net: "none"
net: "container:[name or id]"
2014-06-19 12:57:55 +02:00
net: "host"
2014-07-12 18:45:11 +02:00
```
2014-07-18 03:11:50 +02:00
### dns
Custom DNS servers. Can be a single value or a list.
```
dns: 8.8.8.8
dns:
- 8.8.8.8
- 9.9.9.9
```
2014-07-23 00:36:32 +02:00
2014-11-06 20:38:58 +01:00
### cap_add, cap_drop
Add or drop container capabilities.
See `man 7 capabilities` for a full list.
```
cap_add:
- ALL
cap_drop:
- NET_ADMIN
- SYS_ADMIN
```
2014-08-17 15:18:24 +02:00
### dns_search
Custom DNS search domains. Can be a single value or a list.
```
dns_search: example.com
2014-10-01 18:40:50 +02:00
dns_search:
2014-08-17 15:18:24 +02:00
- dc1.example.com
- dc2.example.com
```
2014-10-28 16:31:09 +01:00
### working\_dir, entrypoint, user, hostname, domainname, mem\_limit, privileged, restart
2014-07-23 00:36:32 +02:00
Each of these is a single value, analogous to its [docker run ](https://docs.docker.com/reference/run/ ) counterpart.
```
working_dir: /code
entrypoint: /code/entrypoint.sh
user: postgresql
hostname: foo
domainname: foo.com
mem_limit: 1000000000
privileged: true
2014-10-28 16:31:09 +01:00
restart: always
2014-07-23 00:36:32 +02:00
```