Managing application Data in Containers
- Every Container gets a read write layer extra on top of image layers
- Two concerns to be addressed are
- How does docker container mount image layers + R/W layer as one file system ?
- Storage Drivers
- How to preserve the data which is present in R/W Layer
- Docker Volumes
- How does docker container mount image layers + R/W layer as one file system ?
Storage Drivers
- Copy-on-write Strategy:
- We need a file system which understands image layers and R/W Layers and to the continer it should be file system much like any other linux/Windows file system
- Storage Driver understands read only image layers, Read/Write Thin layer of container and combines (union) the layers to give one filesystem to container
- Docker has the following storage drivers
- overlay2: This is preferred storage driver for all linux distributions
- aufs: This was preferred storage driver for Docker 18.06 and previous versions
- devicemapper
- btrfs and zfs
- Refer Here for article on storage drivers
Docker Volumes
- Refer Here for article on Docker Volumes
- By default all the files created by container are stored on thin R/w layer. This layer will be existing on a system as long as container exists. Once the container is deleted this data will be lost
- Docker has two options for storing the files on the host machine, so that the changes done in the container are persisted even after contianer is deleted.
- Volumes
- Bind Mount
- Create a Docker Image from the file without Volume instruction and with volume instruction Refer Here for changeset
- Now lets create a docker container from image without volume instruction and other with volume instruction
- Even after the container is terminated data will still exist on the docker host
- What if the VOLUME instruction is not used in Docker Image?
- If your organization is running some kind of third party storage like netapp, vsphere storage etc Refer Here to install volume drivers
- Refer Here for cloud related storage drivers
Host Network and Guest Network in Networking
Docker Networking
- Launch a virtual machine with plain os (ubuntu /centos).
- Execute the command ifconfig
- Now lets install docker and then execute ifconfig
- Now just run the following command
docker container run -d --name my-cont-1 tomcat:jdk8-openjdk
docker container inspect my-cont-1
- Now execute ifconfig
- What is happening to make containers accesible via host network?