Docker Feature¶
Adds docker capabilities to your package, using either “docker build” or “rocker build” to create an image containing your code, in a fully functionnal python virtualenv.
Usage¶
To use the Docker Feature, make sure your Projectfile contains the following:
from medikit import require
docker = require('docker')
The docker handle is a DockerConfig
instance, and can be used to customize the feature.
This feature is brand new and should be used with care.
You’ll get a few make targets out of this, and a Dockerfile (or Rockerfile).
Build¶
Building an image is as simple as running:
$ make docker-build
This will use the root Dockerfile (or Rockerfile, see builders below) and build an image named after your package.
Run¶
You can run the default entrypoint / command in a new container using the built image:
$ make docker-run
Custom builder¶
You can change the default docker builder (a.k.a “docker build”) to use rocker (see https://github.com/grammarly/rocker).
docker.use_rocker_builder()
Custom image name or registry¶
If you want to customize the image name, or the target registry (for example if you want to use Amazon Elastic Container Registry, Google Container Registry, Quay, or even a private registry you’re crazy enough to host yourself):
# only override the registry
docker.set_remote(registry='eu.gcr.io')
# override the registry and username, but keep the default image name
docker.set_remote(registry='eu.gcr.io', user='sergey')
# override the image name only
docker.set_remote(name='acme')
Docker Compose¶
The feature will also create an example docker-compose.yml file.
If you don’t want this, you can:
docker.compose_file = None
Or if you want to override its name:
docker.compose_file = 'config/docker/compose.yml'
Please note that this file will only contain a structure skeleton, with no service defined. This is up to you to fill, although we may work on this in the future as an opt-in managed file.