Image Tag Deployment
New
Introduced in 0.4.0
The dokku tags plugin allows you to add docker image tags to the currently deployed app image for versioning and subsequent deployment.
tags <app> # List all app image tags
tags:create <app> <tag> # Add tag to latest running app image
tags:deploy <app> <tag> # Deploy tagged app image
tags:destroy <app> <tag> # Remove app image tag
For exampple, you can list all tags for a given application:
You can also create new tags for that app using the tags:create
function. Tags should conform to the docker tagging specification for your docker version. As of 1.10, that specification is available here, while users of older versions can check the documentation here.
Once the tag is created, you can see the output by running the tags
command again.
Finally, you can also deploy a local image using the tags:deploy
command.
-----> Releasing node-js-app (dokku/node-js-app:v1)...
-----> Deploying node-js-app (dokku/node-js-app:v1)...
-----> Running pre-flight checks
For more efficient zero downtime deployments, create a file CHECKS.
See https://dokku.com/docs/deployment/zero-downtime-deploys/ for examples
CHECKS file not found in container: Running simple container check...
-----> Waiting for 10 seconds ...
-----> Default container check successful!
=====> node-js-app container output:
Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
Recommending WEB_CONCURRENCY=1
> node-js-app@0.1.0 start /app
> node index.js
Node app is running at localhost:5000
=====> end node-js-app container output
-----> Running post-deploy
-----> Configuring node-js-app.dokku.me...
-----> Creating http nginx.conf
-----> Running nginx-pre-reload
Reloading nginx
-----> Shutting down old containers in 60 seconds
=====> 025eec3fa3b442fded90933d58d8ed8422901f0449f5ea0c23d00515af5d3137
=====> Application deployed:
http://node-js-app.dokku.me
Deploying from a Docker Registry
You can alternatively add image pulled from a docker Registry and deploy app from it by using tagging feature. In this example, we are deploying from Docker Hub.
-
Create dokku app as usual
-
Pull image from Docker Hub
-
Retag the image to match the created app
-
Deploy tag
Note
When deploying an image, we will use docker inspect
to extract the ExposedPorts
configuration and if defined, use that to populate DOKKU_DOCKERFILE_PORTS
. If this behavior is not desired, you can override that configuration variable with the config:set
command.
Example: dokku config:set test-app DOKKU_DOCKERFILE_PORTS="5984/tcp 80/tcp"
Deploying an image from CI
To ensure your builds are always reproducible, it's considered bad practice to store build artifacts in your repository. For some projects however, building artifacts during deployment to dokku may affect the performance of running applications.
One solution is to build a finished Docker image on a CI service (or even locally) and deploy it directly to the host running dokku.
-
Build image on CI (or locally)
-
Deploy image to dokku host
Note
You can also use a Docker Registry to push and pull the image rather than uploading it directly.
Here's a more complete example using the above method:
# build the image
docker build -t dokku/test-app:v12
# copy the image to the dokku host
docker save dokku/test-app:v12 | bzip2 | ssh my.dokku.host "bunzip2 | docker load"
# tag and deploy the image
ssh my.dokku.host "dokku tags:create test-app previous; dokku tags:deploy test-app v12 && dokku tags:create test-app latest"