21 Days of Docker-Day 12-Docker Storage – Part 1

Changing the Storage Driver

NOTE: When you change the storage driver, any existing images and containers become inaccessible. This is because their layers cannot be used by the new storage driver. If you revert your changes, you can access the old images and containers again, but any that you pulled or created using the new driver is then inaccessible.

  • Stop the docker daemon
$ sudo systemctl stop docker
  • Go to /etc/docker/
  • Create a file
$ sudo cat daemon.json
{
  "storage-driver": "devicemapper"
}
  • Start the docker daemon
sudo systemctl start docker
  • Verify the images, you pulled using overlay2 driver
$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

NOTE: As mentioned above any existing images and containers become inaccessible, when we change the storage driver.

Also this I am doing it for testing purpose, When possible, overlay2 is the recommended storage driver.

  • Let’s me revert it back to overlay2
  • Stop the docker daemon
$ sudo systemctl stop docker
$ sudo cat /etc/docker/daemon.json 
{
  "storage-driver": "overlay2"
}
$ sudo systemctl start docker
  • Verify the images, you pulled earlier
$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
alpine              latest              961769676411        8 weeks ago         5.58MB

Before I wrap for the day, let discuss about Storage models

Storage models: Persistent data can be managed using several storage models.

Filesystem storage

  • Data is stored in the form of a file in a regular file system
  • It uses memory very efficiently
  • Used by overlay2 and aufs
  • Inefficient with write-heavy workloads i.e if you are constantly using data

Block Storage

  • Requires a separate device to store data
  • Stores data in the form of fixed sized blocks
  • Used by devicemapper
  • Efficient with write-heavy workloads

To get the blocksize in your system

# blockdev --getbsz /dev/xvda1
512

Object Storage

  • Stores data in an external object-based store.
  • The application must be designed to use object based storage
  • We may need to use restful api to store/access the data
  • Easily flexible and scalable, stores virtually unlimited files
  • Maintain file revisions.
  • HTTP(S) based interface.

Please follow me with my Journey

This time to make learning more interactive, I am adding

  • Slack
  • Meetup

Please feel free to join this group.

Slack: 

https://100daysofdevops.slack.com/join/shared_invite/enQtNzg1MjUzMzQzMzgxLWM4Yjk0ZWJiMjY4ZWE3ODBjZjgyYTllZmUxNzFkNTgxZjQ4NDlmZjkzODAwNDczOTYwOTM2MzlhZDNkM2FkMDA

Meetup Group

If you are in the bay area, please join this meetup group https://www.meetup.com/100daysofdevops/