This commit is contained in:
Aanand Prasad 2014-10-16 19:13:06 +01:00
commit f9b733a718
8 changed files with 95 additions and 51 deletions

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/fig.css?20140808310756672680036">
<link rel="stylesheet" type="text/css" href="css/fig.css?20141016411875515447359">
<link rel="canonical" href="http://www.fig.sh/cli.html">
</head>
<body>
@ -24,33 +24,43 @@
<p>Run <code>fig [COMMAND] --help</code> for full usage.</p>
<h2>build</h2>
<h2>Commands</h2>
<h3>build</h3>
<p>Build or rebuild services.</p>
<p>Services are built once and then tagged as <code>project_service</code>, e.g. <code>figtest_db</code>. If you change a service&#39;s <code>Dockerfile</code> or the contents of its build directory, you can run <code>fig build</code> to rebuild it.</p>
<h2>help</h2>
<h3>help</h3>
<p>Get help on a command.</p>
<h2>kill</h2>
<h3>kill</h3>
<p>Force stop service containers.</p>
<h2>logs</h2>
<h3>logs</h3>
<p>View output from services.</p>
<h2>ps</h2>
<h3>port</h3>
<p>Print the public port for a port binding</p>
<h3>ps</h3>
<p>List containers.</p>
<h2>rm</h2>
<h3>pull</h3>
<p>Pulls service images.</p>
<h3>rm</h3>
<p>Remove stopped service containers.</p>
<h2>run</h2>
<h3>run</h3>
<p>Run a one-off command on a service.</p>
@ -62,12 +72,12 @@
<p>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.</p>
<p>Links are also created between one-off commands and the other containers for that service so you can do stuff like this:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run db /bin/sh -c &quot;psql -h \$DB_1_PORT_5432_TCP_ADDR -U docker&quot;
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run db psql -h db -U docker
</code></pre></div>
<p>If you do not want linked containers to be started when running the one-off command, specify the <code>--no-deps</code> flag:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run --no-deps web python manage.py shell
</code></pre></div>
<h2>scale</h2>
<h3>scale</h3>
<p>Set number of containers to run for a service.</p>
@ -75,15 +85,15 @@
For example:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig scale web=2 worker=3
</code></pre></div>
<h2>start</h2>
<h3>start</h3>
<p>Start existing containers for a service.</p>
<h2>stop</h2>
<h3>stop</h3>
<p>Stop running containers without removing them. They can be started again with <code>fig start</code>.</p>
<h2>up</h2>
<h3>up</h3>
<p>Build, (re)create, start and attach to containers for a service.</p>
@ -92,6 +102,32 @@ For example:</p>
<p>By default, <code>fig up</code> will aggregate the output of each container, and when it exits, all containers will be stopped. If you run <code>fig up -d</code>, it&#39;ll start the containers in the background and leave them running.</p>
<p>By default if there are existing containers for a service, <code>fig up</code> will stop and recreate them (preserving mounted volumes with <a href="http://docs.docker.io/en/latest/use/working_with_volumes/">volumes-from</a>), so that changes in <code>fig.yml</code> are picked up. If you do no want containers to be stopped and recreated, use <code>fig up --no-recreate</code>. This will still start any stopped containers, if needed.</p>
<h2>Environment Variables</h2>
<p>Several environment variables can be used to configure Fig&#39;s behaviour.</p>
<p>Variables starting with <code>DOCKER_</code> are the same as those used to configure the Docker command-line client. If you&#39;re using boot2docker, <code>$(boot2docker shellinit)</code> will set them to their correct values.</p>
<h3>FIG_PROJECT_NAME</h3>
<p>Set the project name, which is prepended to the name of every container started by Fig. Defaults to the <code>basename</code> of the current working directory.</p>
<h3>FIG_FILE</h3>
<p>Set the path to the <code>fig.yml</code> to use. Defaults to <code>fig.yml</code> in the current working directory.</p>
<h3>DOCKER_HOST</h3>
<p>Set the URL to the docker daemon. Defaults to <code>unix:///var/run/docker.sock</code>, as with the docker client.</p>
<h3>DOCKER_TLS_VERIFY</h3>
<p>When set to anything other than an empty string, enables TLS communication with the daemon.</p>
<h3>DOCKER_CERT_PATH</h3>
<p>Configure the path to the <code>ca.pem</code>, <code>cert.pem</code> and <code>key.pem</code> files used for TLS verification. Defaults to <code>~/.docker</code>.</p>
</div>
<div class="sidebar">

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/fig.css?20140808310756672680036">
<link rel="stylesheet" type="text/css" href="css/fig.css?20141016411875515447359">
<link rel="canonical" href="http://www.fig.sh/django.html">
</head>
<body>
@ -67,7 +67,7 @@ Dockerfile fig.yml figexample manage.py requirements
&#39;ENGINE&#39;: &#39;django.db.backends.postgresql_psycopg2&#39;,
&#39;NAME&#39;: &#39;postgres&#39;,
&#39;USER&#39;: &#39;postgres&#39;,
&#39;HOST&#39;: &#39;db_1&#39;,
&#39;HOST&#39;: &#39;db&#39;,
&#39;PORT&#39;: 5432,
}
}
@ -90,7 +90,7 @@ myapp_web_1 | Django version 1.6.1, using settings &#39;figexample.settings&#39;
myapp_web_1 | Starting development server at http://0.0.0.0:8000/
myapp_web_1 | Quit the server with CONTROL-C.
</code></pre></div>
<p>And your Django app should be running at <a href="http://localhost:8000">localhost:8000</a> (or <a href="http://localdocker:8000">localdocker:8000</a> if you&#39;re using docker-osx).</p>
<p>And your Django app should be running at port 8000 on your docker daemon (if you&#39;re using boot2docker, <code>boot2docker ip</code> will tell you its address).</p>
<p>You can also run management commands with Docker. To set up your database, for example, run <code>fig up</code> and in another terminal run:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run web python manage.py syncdb

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/fig.css?20140808310756672680036">
<link rel="stylesheet" type="text/css" href="css/fig.css?20141016411875515447359">
<link rel="canonical" href="http://www.fig.sh/env.html">
</head>
<body>
@ -20,24 +20,26 @@
<div class="content"><h1>Environment variables reference</h1>
<p>Fig uses <a href="http://docs.docker.io/en/latest/use/port_redirection/#linking-a-container">Docker links</a> to expose services&#39; containers to one another. Each linked container injects a set of environment variables, each of which begins with the uppercase name of the container.</p>
<p><strong>Note:</strong> 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 <a href="yml.html#links">fig.yml documentation</a> for details.</p>
<p>Fig uses <a href="http://docs.docker.com/userguide/dockerlinks/">Docker links</a> to expose services&#39; containers to one another. Each linked container injects a set of environment variables, each of which begins with the uppercase name of the container.</p>
<p>To see what environment variables are available to a service, run <code>fig run SERVICE env</code>.</p>
<p><b><i>name</i>_PORT</b><br>
Full URL, e.g. <code>DB_1_PORT=tcp://172.17.0.5:5432</code></p>
Full URL, e.g. <code>DB_PORT=tcp://172.17.0.5:5432</code></p>
<p><b><i>name</i>_PORT_<i>num</i>_<i>protocol</i></b><br>
Full URL, e.g. <code>DB_1_PORT_5432_TCP=tcp://172.17.0.5:5432</code></p>
Full URL, e.g. <code>DB_PORT_5432_TCP=tcp://172.17.0.5:5432</code></p>
<p><b><i>name</i>_PORT_<i>num</i>_<i>protocol</i>_ADDR</b><br>
Container&#39;s IP address, e.g. <code>DB_1_PORT_5432_TCP_ADDR=172.17.0.5</code></p>
Container&#39;s IP address, e.g. <code>DB_PORT_5432_TCP_ADDR=172.17.0.5</code></p>
<p><b><i>name</i>_PORT_<i>num</i>_<i>protocol</i>_PORT</b><br>
Exposed port number, e.g. <code>DB_1_PORT_5432_TCP_PORT=5432</code></p>
Exposed port number, e.g. <code>DB_PORT_5432_TCP_PORT=5432</code></p>
<p><b><i>name</i>_PORT_<i>num</i>_<i>protocol</i>_PROTO</b><br>
Protocol (tcp or udp), e.g. <code>DB_1_PORT_5432_TCP_PROTO=tcp</code></p>
Protocol (tcp or udp), e.g. <code>DB_PORT_5432_TCP_PROTO=tcp</code></p>
<p><b><i>name</i>_NAME</b><br>
Fully qualified container name, e.g. <code>DB_1_NAME=/myapp_web_1/myapp_db_1</code></p>

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/fig.css?20140808310756672680036">
<link rel="stylesheet" type="text/css" href="css/fig.css?20141016411875515447359">
<link rel="canonical" href="http://www.fig.sh/">
</head>
<body>
@ -67,7 +67,7 @@ $ cd figtest
<span class="kn">from</span> <span class="nn">redis</span> <span class="kn">import</span> <span class="n">Redis</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="n">app</span> <span class="o">=</span> <span class="n">Flask</span><span class="p">(</span><span class="n">__name__</span><span class="p">)</span>
<span class="n">redis</span> <span class="o">=</span> <span class="n">Redis</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s">&quot;redis_1&quot;</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">6379</span><span class="p">)</span>
<span class="n">redis</span> <span class="o">=</span> <span class="n">Redis</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s">&#39;redis&#39;</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">6379</span><span class="p">)</span>
<span class="nd">@app.route</span><span class="p">(</span><span class="s">&#39;/&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">hello</span><span class="p">():</span>
@ -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/
</code></pre></div>
<p>Open up <a href="http://localhost:5000">http://localhost:5000</a> in your browser (or <a href="http://localdocker:5000">http://localdocker:5000</a> if you&#39;re using <a href="https://github.com/noplay/docker-osx">docker-osx</a>) and you should see it running!</p>
<p>The web app should now be listening on port 5000 on your docker daemon (if you&#39;re using boot2docker, <code>boot2docker ip</code> will tell you its address).</p>
<p>If you want to run your services in the background, you can pass the <code>-d</code> flag to <code>fig up</code> and use <code>fig ps</code> to see what is currently running:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig up -d

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/fig.css?20140808310756672680036">
<link rel="stylesheet" type="text/css" href="css/fig.css?20141016411875515447359">
<link rel="canonical" href="http://www.fig.sh/install.html">
</head>
<body>
@ -20,22 +20,19 @@
<div class="content"><h1>Installing Fig</h1>
<p>First, install Docker version 1.0 or greater. If you&#39;re on OS X, you can use <a href="https://github.com/noplay/docker-osx">docker-osx</a>:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ curl https://raw.githubusercontent.com/noplay/docker-osx/1.1.1/docker-osx &gt; /usr/local/bin/docker-osx
$ chmod +x /usr/local/bin/docker-osx
$ docker-osx shell
</code></pre></div>
<p>Docker has guides for <a href="http://docs.docker.io/en/latest/installation/ubuntulinux/">Ubuntu</a> and <a href="http://docs.docker.io/en/latest/installation/">other platforms</a> in their documentation.</p>
<p>First, install Docker version 1.3 or greater.</p>
<p>Next, install Fig. On OS X:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ curl -L https://github.com/docker/fig/releases/download/0.5.2/darwin &gt; /usr/local/bin/fig
$ chmod +x /usr/local/bin/fig
<p>If you&#39;re on OS X, you can use the <a href="https://docs.docker.com/installation/mac/">OS X installer</a> to install both Docker and boot2docker. Once boot2docker is running, set the environment variables that&#39;ll configure Docker and Fig to talk to it:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$(boot2docker shellinit)
</code></pre></div>
<p>On 64-bit Linux:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ curl -L https://github.com/docker/fig/releases/download/0.5.2/linux &gt; /usr/local/bin/fig
$ chmod +x /usr/local/bin/fig
<p>To persist the environment variables across shell sessions, you can add that line to your <code>~/.bashrc</code> file.</p>
<p>There are also guides for <a href="https://docs.docker.com/installation/ubuntulinux/">Ubuntu</a> and <a href="https://docs.docker.com/installation/">other platforms</a> in Docker’s documentation.</p>
<p>Next, install Fig:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">curl -L https://github.com/docker/fig/releases/download/1.0.0/fig-`uname -s`-`uname -m` &gt; /usr/local/bin/fig; chmod +x /usr/local/bin/fig
</code></pre></div>
<p>Fig is also available as a Python package if you&#39;re on another platform (or if you prefer that sort of thing):</p>
<p>Releases are available for OS X and 64-bit Linux. Fig is also available as a Python package if you&#39;re on another platform (or if you prefer that sort of thing):</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ sudo pip install -U fig
</code></pre></div>
<p>That should be all you need! Run <code>fig --version</code> to see if it worked.</p>

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/fig.css?20140808310756672680036">
<link rel="stylesheet" type="text/css" href="css/fig.css?20141016411875515447359">
<link rel="canonical" href="http://www.fig.sh/rails.html">
</head>
<body>
@ -79,7 +79,7 @@ Rakefile db test
pool: 5
username: postgres
password:
host: db_1
host: db
test:
&lt;&lt;: *default
@ -96,7 +96,7 @@ myapp_web_1 | [2014-01-17 17:16:29] INFO WEBrick::HTTPServer#start: pid=1 port=
<p>Finally, we just need to create the database. In another terminal, run:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">$ fig run web rake db:create
</code></pre></div>
<p>And we&#39;re rolling—see for yourself at <a href="http://localhost:3000">localhost:3000</a> (or <a href="http://localdocker:3000">localdocker:3000</a> if you&#39;re using docker-osx).</p>
<p>And we&#39;re rolling—your app should now be running on port 3000 on your docker daemon (if you&#39;re using boot2docker, <code>boot2docker ip</code> will tell you its address).</p>
<p><img src="https://orchardup.com/static/images/fig-rails-screenshot.png" alt="Screenshot of Rails&#39; stock index.html"></p>
</div>

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/fig.css?20140808310756672680036">
<link rel="stylesheet" type="text/css" href="css/fig.css?20141016411875515447359">
<link rel="canonical" href="http://www.fig.sh/wordpress.html">
</head>
<body>
@ -49,7 +49,7 @@ db:
define(&#39;DB_NAME&#39;, &#39;wordpress&#39;);
define(&#39;DB_USER&#39;, &#39;root&#39;);
define(&#39;DB_PASSWORD&#39;, &#39;&#39;);
define(&#39;DB_HOST&#39;, getenv(&quot;DB_1_PORT_3306_TCP_ADDR&quot;) . &quot;:&quot; . getenv(&quot;DB_1_PORT_3306_TCP_PORT&quot;));
define(&#39;DB_HOST&#39;, &quot;db:3306&quot;);
define(&#39;DB_CHARSET&#39;, &#39;utf8&#39;);
define(&#39;DB_COLLATE&#39;, &#39;&#39;);
@ -89,7 +89,7 @@ if(file_exists($root.$path))
}
}else include_once &#39;index.php&#39;;
</code></pre></div>
<p>With those four files in place, run <code>fig up</code> inside your Wordpress directory and it&#39;ll pull and build the images we need, and then start the web and database containers. You&#39;ll then be able to visit Wordpress and set it up by visiting <a href="http://localhost:8000">localhost:8000</a> - or <a href="http://localdocker:8000">localdocker:8000</a> if you&#39;re using docker-osx.</p>
<p>With those four files in place, run <code>fig up</code> inside your Wordpress directory and it&#39;ll pull and build the images we need, and then start the web and database containers. You&#39;ll then be able to visit Wordpress at port 8000 on your docker daemon (if you&#39;re using boot2docker, <code>boot2docker ip</code> will tell you its address).</p>
</div>
<div class="sidebar">

View file

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lilita+One|Lato:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/fig.css?20140808310756672680036">
<link rel="stylesheet" type="text/css" href="css/fig.css?20141016411875515447359">
<link rel="canonical" href="http://www.fig.sh/yml.html">
</head>
<body>
@ -41,14 +41,23 @@ image: a4bc65fd
<p>Override the default command.</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">command: bundle exec thin -p 3000
</code></pre></div>
<p><a name="links"></a></p>
<h3>links</h3>
<p>Link to containers in another service. Optionally specify an alternate name for the link, which will determine how environment variables are prefixed, e.g. <code>db</code> -&gt; <code>DB_1_PORT</code>, <code>db:database</code> -&gt; <code>DATABASE_1_PORT</code></p>
<p>Link to containers in another service. Either specify both the service name and the link alias (<code>SERVICE:ALIAS</code>), or just the service name (which will also be used for the alias).</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">links:
- db
- db:database
- redis
</code></pre></div>
<p>An entry with the alias&#39; name will be created in <code>/etc/hosts</code> inside containers for this service, e.g:</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">172.17.2.186 db
172.17.2.186 database
172.17.2.187 redis
</code></pre></div>
<p>Environment variables will also be created - see the <a href="env.html">environment variable reference</a> for details.</p>
<h3>ports</h3>
<p>Expose ports. Either specify both ports (<code>HOST:CONTAINER</code>), or just the container port (a random host port will be chosen).</p>
@ -69,12 +78,12 @@ image: a4bc65fd
</code></pre></div>
<h3>volumes</h3>
<p>Mount paths as volumes, optionally specifying a path on the host machine (<code>HOST:CONTAINER</code>).</p>
<p>Note: Mapping local volumes is currently unsupported on boot2docker. We recommend you use <a href="https://github.com/noplay/docker-osx">docker-osx</a> if want to map local volumes.</p>
<p>Mount paths as volumes, optionally specifying a path on the host machine
(<code>HOST:CONTAINER</code>), or an access mode (<code>HOST:CONTAINER:ro</code>).</p>
<div class="highlight"><pre><code class="text language-text" data-lang="text">volumes:
- /var/lib/mysql
- cache/:/tmp/cache
- ~/configs:/etc/configs/:ro
</code></pre></div>
<h3>volumes_from</h3>