官术网_书友最值得收藏!

Persistent storage

As you remember from Chapter 1, Introduction to Docker, the Docker container filesystem is kind of temporary by default. If you start up a Docker image (that is, run the container), you'll end up with a read-write layer on top of the layers stack. You can create, modify, and delete files as you wish; if you commit the changes back into the image, they will become persisted. This is a great feature if you want to create a complete setup of your application in the image, altogether with all its environment. But, this is not very convenient when it comes to storing and retrieving data. The best option would be to separate the container life cycle and your application from the data. Ideally, you would probably want to keep these separate, so that the data generated (or being used) by your application is not destroyed or tied to the container life cycle and can thus be reused.

The perfect example would be a web application server: the Docker image contains web server software, the same as Tomcat for example, with your Java application deployed, configured, and ready to use. But, the data the server will be using should be separated from the image. This is done via volumes, which we will focus on in this part of the chapter. Volumes are not part of the union filesystem, and so the write operations are instant and as fast as possible, there is no need to commit any changes.

Volumes live outside of the union filesystem and exist as normal directories and files on the host filesystem.

There are three main use cases for Docker data volumes:

  • To share data between the host filesystem and the Docker container
  • To keep data when a container is removed
  • To share data with other Docker containers

Let's begin with a list of volume-related commands at our disposal.

主站蜘蛛池模板: 永平县| 顺平县| 石河子市| 长顺县| 余干县| 枞阳县| 定州市| 望奎县| 仙居县| 绥滨县| 天台县| 香河县| 新巴尔虎左旗| 孟连| 读书| 蓬溪县| 宁强县| 札达县| 前郭尔| 青神县| 金华市| 黄平县| 于田县| 房产| 修水县| 兴隆县| 乐安县| 石景山区| 泌阳县| 平泉县| 专栏| 克什克腾旗| 华亭县| 南和县| 环江| 盘锦市| 沛县| 宿松县| 额济纳旗| 睢宁县| 西乌珠穆沁旗|