Docker inspect format labels2/18/2023 ![]() ![]() ![]() The most direct way is declare a volume at run-time with the -v flag:ĭocker run -it -name vol-test -h CONTAINER -v /data debian /bin/bash There are several ways to initialise volumes, with some subtle differences that are important to understand. ![]() ![]() Quite simply, volumes are directories (or files) that are outside of the default Union File System and exist as normal directories and files on the host filesystem. In order to be able to save (persist) data and also to share data between containers, Docker came up with the concept of volumes. Docker calls this combination of read-only layers with a read-write layer on top a Union File System. When a Docker container is deleted, relaunching the image will start a fresh container without any of the changes made in the previously running container - those changes are lost. The version in the read-write layer hides the underlying file, but does not destroy it - it still exists in the underlying layer. If the running container modifies an existing file, the file is copied out of the underlying read-only layer and into the top-most read-write layer where the changes are applied. When we start a container, Docker takes the read-only image and adds a read-write layer on top. Docker images are stored as series of read-only layers. In order to understand what a Docker volume is, we first need to be clear about how the filesystem normally works in Docker. Whilst this post is primarily aimed at Docker users with little to no knowledge of volumes, even experienced users are likely to learn something as there are some subtleties that many people aren't aware of. In this post, I'll try to explain how volumes work and present some best practices. It's clear from looking at the questions asked on the Docker IRC channel (#docker on Freenode), Slack and Stackoverflow that there's a lot of confusion over how volumes work in Docker. This post was updated on to cover new versions of Docker. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |