Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deliver docker image to client?

Tags:

docker

A client wants a docker app delivered. I have two questions regarding best practices.

First, I need to deliver an app with tomcat, a webapp, a database, and some tables. I understand how to set up tomcat and the database, but what do you do with their assets (ie webapp and tables)? Do you include them in the image and then push this to hub.docker.com? If the webapp and database tables are proprietary, how do you deal with that? Do you create a private image and share it somehow?

Second, as the app runs, the database tables may change. As I understand it (and tested), docker containers are stateless so once it's stopped, the data is reset. How do you maintain the same state between restarts? I know you can map folders between the container and host, but do I really ship a separate database folder containing the data and have the docker container map it? What's the best practice here?

Thanks in advance

Edit First of all, thank you to everyone who replied back. Both @RicardoBranco and @kstromeiraos have good suggestions for how to distribute the image. I don't know which the client prefers yet and while I'd like to award both of you the checkmark, SO only allows me to award one answer. So I've upvoted you both and will let the internet decide which answer prevails in the long run.

Second, I'm an idiot. I was using the "docker run" command to "start" my container, which I now realize is creating a new container, making me believe that I had lost all my data from the previous session. It was only after I realized that you should be calling "docker start" to "start" a container that I noticed my mistake in understanding.

Thank you all

like image 761
kane Avatar asked Jun 13 '17 00:06

kane


2 Answers

  1. You have two options to distribute the images.

    • As @Ricardo Branco said, use a private registry.

    • Use docker save to save images to tar files and then, share that with your client whom can use them by loading them using docker load (https://docs.docker.com/engine/reference/commandline/save/).

  2. You should have a volume in which your DB data persists. You can map a host directory.

    To backup volumes, take a look to this useful tool which allows you to do that. https://github.com/discordianfish/docker-backup

like image 125
kstromeiraos Avatar answered Sep 30 '22 14:09

kstromeiraos


  1. You can create a private repository in Docker Hub (or Amazon EC2 Container Registry) or setup a Docker Registry yourself with TLS and some form of user authentation (with TLS client certificate and/or HTTP basic auth):

https://docs.docker.com/registry/

  1. No data is reset when the container is stopped, only when the container (and associated volumes) is removed. Containers are meant to be ephemeral instances of code operating on data (volumes).
like image 20
Ricardo Branco Avatar answered Sep 30 '22 12:09

Ricardo Branco