user1903825
user1903825

Reputation:

How exactly does docker work? (Theory)

I am venturing into using docker and trying to get a firm grasp of the product.

While I love everything it promises it is a big change from doing things manually.

Right now I understand how to build a container, attach your code, commit and push it to your repo.

But what I am really wondering is how do I update my code once deployed, for example, I have some minor bug fixes but no change to dependencies but I also run a database in the same container.

Container:

Node & NPM

Nginx

Mysql

php

Right now the only way I understand you can do it is to close thje container re pull the new container and run, but I am thinking you will lose database data.

I have been reading into https://docs.docker.com/engine/tutorials/dockervolumes/ and thinking maybe the container mounts a data file that persists between containers.

What I am trying to do is run a web app/website with the above container layout and just change code with latest bugfixes/features.

Upvotes: 0

Views: 452

Answers (1)

Sobrique
Sobrique

Reputation: 53498

You're quite correct. Docker images are something you should be rebuilding and discarding with each update - avoid commit wherever possible (outside your build scripts anyway).

Persistent state should be managed via data containers that you then mount with your image. Thus your "data" is decoupled from that specific version and instance of the application.

Upvotes: 1

Related Questions