This example shows how to deploy configuration consisting of a single container based on custom image which automatically built from provided Dockerfile.
- Fabricio 0.4.6 or greater
- Vagrant
- One from the list of Vagrant supported providers (this example was tested with VirtualBox)
- Docker for Linux/Mac/Windows
- Docker registry which runs locally on 5000 port, this can be reached out by executing following docker command:
docker run --name registry --publish 5000:5000 --detach registry:2
- Dockerfile, used for building image
- fabfile.py, Fabricio configuration
- README.md, this file
- Vagrantfile, Vagrant config
Run vagrant up
and wait until VM will be created.
fab --list
fab app
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
See also "Hello World" Customization section.
You can provide custom folder with Dockerfile
by passing build_path
parameter to ImageBuildDockerTasks
:
from fabricio import tasks
nginx = tasks.ImageBuildDockerTasks(
# ...
build_path='path/to/folder/with/dockerfile',
)
Any docker build
option can be passed directly to prepare
command*:
fab app.prepare:tag,file=my-Dockerfile,squash=yes
* Fabricio uses --pull
and --force-rm
options by default. However, these can be revoked: prepare:pull=no,force-rm=no
.
If you wish use custom docker build
options then you have to call push
and upgrade
commands manually to finish deploy:
fab app.push:tag
fab app.upgrade:tag
Or, all in one line:
fab app.prepare:tag,file=my-Dockerfile,squash=yes app.push:tag app.upgrade:tag
See also how's Fabric work with per-task arguments.
- Windows users may fall into trouble with
VirtualBox
andHyper-V
, the latter is used by "native" Docker for Windows. Try to disable Hyper-V and use Docker Toolbox instead in such case