Building Docker Images #
Quantum nodes run as Swarm instances, which means that when you want to deploy an application, you’ll have to build Docker images first. Swarm doesn’t allow (or recommend) for building on the nodes as builds are not distributed and due to resource usage can have an impact on the availability of services running on your cluster.
The following guide uses
dockercommands, please do not use
docker-compose buildto create images.
There are a few things you should have & know in advance:
- Docker installed and running
- Do you have a private Docker registry?
- Or is the code public?
Private registries #
Gitlab, Github, Docker Hub, or self-hosted — if neither of these options is for you, please get in touch as we offer a private registry for our customers as well.
For private registries, please get the full URL/name of your registry.
For example registry.example.org.
To build an image, use the following commands:
$ docker login https://registry.company.org
# the following assumes a "Dockerfile" is in the same directory
$ docker build -t registry.example.org/project/image:latest .
$ docker push registry.example.org/project/image:latest
Public registries #
Release code and images as open-source? Great! Here are a few guidelines.
The most well-known options for public registries are:
In order to build an image, use the following commands:
# Docker Hub
$ docker login
$ docker build -t project/image:latest .
$ docker push project/image:latest
Or for quay.io:
$ docker login quay.io
$ docker build -t quay.io/project/image:latest .
$ docker push quay.io/project/image:latest
Quay.io in particular provides integration with common SCMs and supports automatic building when you push a commit, branch or tag.
Always consider using CI to build your image. Repeatable builds are the best builds! We have a few notes on Drone.io or Gitlab in our documentation.
- Better Docker images come with more tags than
- Keep semantic versioning in mind, you yourself and others will thank you in the future.
Tagging multiple versions #
latest is a standard, but also frowned upon. You may want to provide it for convenience, but also provide an anchor:
$ docker build -t project/image:latest -t project/image:1.1 .
As always, if you run into obstacles along the way — please get in touch with us!