Services are built once and then tagged as project_service, e.g. figtest_db. If you change a service's Dockerfile or the contents of its build directory, you can run fig build to rebuild it.
-
help
+
help
Get help on a command.
-
kill
+
kill
Force stop service containers.
-
logs
+
logs
View output from services.
-
ps
+
port
+
+
Print the public port for a port binding
+
+
ps
List containers.
-
rm
+
pull
+
+
Pulls service images.
+
+
rm
Remove stopped service containers.
-
run
+
run
Run a one-off command on a service.
@@ -62,12 +72,12 @@
One-off commands are started in new containers with the same config as a normal container for that service, so volumes, links, etc will all be created as expected. The only thing different to a normal container is the command will be overridden with the one specified and no ports will be created in case they collide.
Links are also created between one-off commands and the other containers for that service so you can do stuff like this:
-
$ fig run db /bin/sh -c "psql -h \$DB_1_PORT_5432_TCP_ADDR -U docker"
+
$ fig run db psql -h db -U docker
If you do not want linked containers to be started when running the one-off command, specify the --no-deps flag:
$ fig run --no-deps web python manage.py shell
-
scale
+
scale
Set number of containers to run for a service.
@@ -75,15 +85,15 @@
For example:
$ fig scale web=2 worker=3
-
start
+
start
Start existing containers for a service.
-
stop
+
stop
Stop running containers without removing them. They can be started again with fig start.
-
up
+
up
Build, (re)create, start and attach to containers for a service.
@@ -92,6 +102,32 @@ For example:
By default, fig up will aggregate the output of each container, and when it exits, all containers will be stopped. If you run fig up -d, it'll start the containers in the background and leave them running.
By default if there are existing containers for a service, fig up will stop and recreate them (preserving mounted volumes with volumes-from), so that changes in fig.yml are picked up. If you do no want containers to be stopped and recreated, use fig up --no-recreate. This will still start any stopped containers, if needed.
+
+
Environment Variables
+
+
Several environment variables can be used to configure Fig's behaviour.
+
+
Variables starting with DOCKER_ are the same as those used to configure the Docker command-line client. If you're using boot2docker, $(boot2docker shellinit) will set them to their correct values.
+
+
FIG_PROJECT_NAME
+
+
Set the project name, which is prepended to the name of every container started by Fig. Defaults to the basename of the current working directory.
+
+
FIG_FILE
+
+
Set the path to the fig.yml to use. Defaults to fig.yml in the current working directory.
+
+
DOCKER_HOST
+
+
Set the URL to the docker daemon. Defaults to unix:///var/run/docker.sock, as with the docker client.
+
+
DOCKER_TLS_VERIFY
+
+
When set to anything other than an empty string, enables TLS communication with the daemon.
+
+
DOCKER_CERT_PATH
+
+
Configure the path to the ca.pem, cert.pem and key.pem files used for TLS verification. Defaults to ~/.docker.
diff --git a/django.html b/django.html
index be1eb11a..0aa369dc 100644
--- a/django.html
+++ b/django.html
@@ -6,7 +6,7 @@
-
+
@@ -67,7 +67,7 @@ Dockerfile fig.yml figexample manage.py requirements
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
- 'HOST': 'db_1',
+ 'HOST': 'db',
'PORT': 5432,
}
}
@@ -90,7 +90,7 @@ myapp_web_1 | Django version 1.6.1, using settings 'figexample.settings'
myapp_web_1 | Starting development server at http://0.0.0.0:8000/
myapp_web_1 | Quit the server with CONTROL-C.
And your Django app should be running at port 8000 on your docker daemon (if you're using boot2docker, boot2docker ip will tell you its address).
You can also run management commands with Docker. To set up your database, for example, run fig up and in another terminal run:
$ fig run web python manage.py syncdb
diff --git a/env.html b/env.html
index 3943dd88..b0ad2a5d 100644
--- a/env.html
+++ b/env.html
@@ -6,7 +6,7 @@
-
+
@@ -20,24 +20,26 @@
Environment variables reference
-
Fig uses Docker links to expose services' containers to one another. Each linked container injects a set of environment variables, each of which begins with the uppercase name of the container.
+
Note: Environment variables are no longer the recommended method for connecting to linked services. Instead, you should use the link name (by default, the name of the linked service) as the hostname to connect to. See the fig.yml documentation for details.
+
+
Fig uses Docker links to expose services' containers to one another. Each linked container injects a set of environment variables, each of which begins with the uppercase name of the container.
To see what environment variables are available to a service, run fig run SERVICE env.
name_PORT
-Full URL, e.g. DB_1_PORT=tcp://172.17.0.5:5432
+Full URL, e.g. DB_PORT=tcp://172.17.0.5:5432
name_PORT_num_protocol
-Full URL, e.g. DB_1_PORT_5432_TCP=tcp://172.17.0.5:5432
+Full URL, e.g. DB_PORT_5432_TCP=tcp://172.17.0.5:5432
name_PORT_num_protocol_ADDR
-Container's IP address, e.g. DB_1_PORT_5432_TCP_ADDR=172.17.0.5
+Container's IP address, e.g. DB_PORT_5432_TCP_ADDR=172.17.0.5
name_PORT_num_protocol_PORT
-Exposed port number, e.g. DB_1_PORT_5432_TCP_PORT=5432
+Exposed port number, e.g. DB_PORT_5432_TCP_PORT=5432
name_PORT_num_protocol_PROTO
-Protocol (tcp or udp), e.g. DB_1_PORT_5432_TCP_PROTO=tcp
+Protocol (tcp or udp), e.g. DB_PORT_5432_TCP_PROTO=tcp
name_NAME
Fully qualified container name, e.g. DB_1_NAME=/myapp_web_1/myapp_db_1
diff --git a/index.html b/index.html
index 9bbb3495..ea1ead53 100644
--- a/index.html
+++ b/index.html
@@ -6,7 +6,7 @@
-
+
@@ -67,7 +67,7 @@ $ cd figtest
fromredisimportRedisimportosapp=Flask(__name__)
-redis=Redis(host="redis_1",port=6379)
+redis=Redis(host='redis',port=6379)@app.route('/')defhello():
@@ -118,7 +118,7 @@ Starting figtest_web_1...
redis_1 | [8] 02 Jan 18:43:35.576 # Server started, Redis version 2.8.3
web_1 | * Running on http://0.0.0.0:5000/
If you're on OS X, you can use the OS X installer to install both Docker and boot2docker. Once boot2docker is running, set the environment variables that'll configure Docker and Fig to talk to it:
Fig is also available as a Python package if you're on another platform (or if you prefer that sort of thing):
+
Releases are available for OS X and 64-bit Linux. Fig is also available as a Python package if you're on another platform (or if you prefer that sort of thing):
$ sudo pip install -U fig
That should be all you need! Run fig --version to see if it worked.
diff --git a/rails.html b/rails.html
index 2d26d9a8..8652bfd9 100644
--- a/rails.html
+++ b/rails.html
@@ -6,7 +6,7 @@
-
+
@@ -79,7 +79,7 @@ Rakefile db test
pool: 5
username: postgres
password:
- host: db_1
+ host: db
test:
<<: *default
@@ -96,7 +96,7 @@ myapp_web_1 | [2014-01-17 17:16:29] INFO WEBrick::HTTPServer#start: pid=1 port=
Finally, we just need to create the database. In another terminal, run:
And we're rolling—your app should now be running on port 3000 on your docker daemon (if you're using boot2docker, boot2docker ip will tell you its address).
With those four files in place, run fig up inside your Wordpress directory and it'll pull and build the images we need, and then start the web and database containers. You'll then be able to visit Wordpress and set it up by visiting localhost:8000 - or localdocker:8000 if you're using docker-osx.
+
With those four files in place, run fig up inside your Wordpress directory and it'll pull and build the images we need, and then start the web and database containers. You'll then be able to visit Wordpress at port 8000 on your docker daemon (if you're using boot2docker, boot2docker ip will tell you its address).
Link to containers in another service. Optionally specify an alternate name for the link, which will determine how environment variables are prefixed, e.g. db -> DB_1_PORT, db:database -> DATABASE_1_PORT
+
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).
links:
- db
- db:database
- redis
+
An entry with the alias' name will be created in /etc/hosts inside containers for this service, e.g:
+
172.17.2.186 db
+172.17.2.186 database
+172.17.2.187 redis
+