Skip to content

Latest commit

 

History

History
111 lines (62 loc) · 4.6 KB

README.md

File metadata and controls

111 lines (62 loc) · 4.6 KB

Fabricio: Hello World

This example shows how to deploy basic configuration consisting of a single container based on official Nginx image.

Requirements

Files

  • fabfile.py, Fabricio configuration
  • README.md, this file
  • Vagrantfile, Vagrant config

Virtual Machine creation

Run vagrant up and wait until VM will be created.

List of available commands

fab --list

Deploy

fab app

Parallel execution

Any Fabricio command can be executed in parallel mode. This mode provides advantages when you have more then one host to deploy to. Use --parallel option if you want to run command on all hosts simultaneously:

fab --parallel app

Deploy idempotency

Whenever you start deploy using serial or parallel mode Fabricio will always check if deploy is really necessary (usually by comparing new image id and image id of current container). Thus, deploy will be skipped if there is nothing to update. However, deploy may be forced using force parameter:

fab app:force=yes

Remove

Use destroy command to completely remove existing service, including all its containers and images:

fab app.destroy

New in 0.5.2

Customization

DockerTasks takes a few additional optional arguments which can be used to customize your deploy process.

Environment variables

env parameter can be used to provide set of environment variables for all commands executed on the remote host:

env={
    FOO='FOO',
    BAR=env.BAR,
}

In the example above BAR takes its value from Fabric env vars which in turn can be set via --set command line option. See Fabric documentation for more details.

New in 0.5.5

Intermediate (proxy) registry

This option usually used when remote host has not direct access to the Docker registry to pull images from. If so, you can provide address and port of custom registry which will be used as an intermediate (or proxy, in other words) image registry for you remote host:

registry='private-registry:5000'

If such parameter as above was provided then Fabricio will always try to pull image from original image's registry and push this image to private-registry:5000 which will be used by remote hosts instead of original one.

Registry account

This option let you to provide custom Docker registry account to use with the registry:

account='my-account'

SSH tunneling

There is also ability to set up reverse SSH tunnel from remote host to your local network. This can be done by providing ssh_tunnel parameter:

ssh_tunnel='7000:example.com:5000'  # value syntax is the same as 'ssh -R' does

Providing such parameter as above will open port 7000 on the remote host for period of deployment and all packets sent to this port will be forwarded to example.com:5000.

Using proxy over SSH tunnel

While Docker can work with proxy you can run HTTP/HTTPS/SOCKS5 proxy and provide remote hosts access to this proxy over SSH tunnel using such parameter value:

ssh_tunnel='33128:proxy-host:3128'

Where 3128 is port which used by proxy running on proxy-host, and 33128 is port used for proxy on the remote side. In this case you must specify HTTP_PROXY=http://localhost:33128 or HTTPS_PROXY=https://localhost:33128 or ALL_PROXY=socks5://localhost:33128 environment variable (depending on type of your proxy) in Docker settings on all remote hosts.

New in 0.4.6

Local registry access over SSH tunnel

Suppose you have your own private registry running on localhost and listening on 5000 port. Then you can provide access to this registry for remote hosts by filling out following parameters:

registry='localhost:5000',
ssh_tunnel='5000:5000',

To set different port (and host) on remote side you can use host_registry:

registry='localhost:5000',
ssh_tunnel='7000:5000',
host_registry='localhost:7000',

New in 0.4.6

Note, that official Docker registry (hub.docker.com) and most other registries behind HTTP router or load balancer (e.g. nginx or apache) will not work over SSH tunnel due to incorrect Host header using by Docker daemon while pulling images over SSH tunnel. But this can be fixed by using proxy.