Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the proper way of deploying versioned applications with docker?

I have a play framework 2.3 application that I'd like to deploy (and keep updating) via docker. If I release a new version of the application, should I build a new docker image every time or build a single docker image that downloads and installs my application via git pull/apt-get?

The Dockerfiles I have seen so far install applications via apt-get (e.g. postgres image) which would mean to deploy a new version of my application I would just have to restart the container which would pull the latest release from a private .deb repository. Rolling back will be a nuisance because I would have to rush to create a new docker to point to a specific package version.

The alternative is to create a new image for each application version. However is that the "right" way to use docker?

like image 676
pavel987 Avatar asked Aug 07 '14 15:08

pavel987


People also ask

How Docker is used for deployment?

In simple terms, Docker is a tool that lets developers to create, deploy, and run applications in containers. Containerization is the use of Linux containers to deploy applications.


1 Answers

You should build a new docker image every time and use the version part of the tag (e.g. :latest and :2.3) to help users pick the right one:

$ docker build -t pavel987/playframework:2.3 .
....
# docker builds
$ docker tag pavel987/playframework:2.3 pavel987/playframework:latest
# Assuming your Docker Hub user name is pavel987
$ docker push pavel987/playframework

Tagging with the version number and with latest lets your users automatically use the newest version (because the CLI will default to use latest) and still lets them pick a consistent version if they don't want things to change (e.g. :2.3). So in their own Dockerfiles they could use FROM pavel987/playframework:latest if they want to use the latest version, or FROM pavel987/playframework:2.3 if they want to pin their base.

This all assumes that you want your primary distribution to be as a Docker image.

like image 57
Andy Avatar answered Oct 22 '22 00:10

Andy