Contents

Kubernetes Docker Storage

Docker File System

1
2
3
4
5
/var/lib/docker
├── aufs
├── containers
├── image
├── volumes

Layered Architecture

First Dockerfile

1
2
3
4
5
6
7
8
9
FROM ubuntu

RUN apt-get update && apt-get -y install python

RUN pip install flask flask-mysql

COPY . /opt/source-code

ENTRYPOINT FLASK_APP=/opt/source-code/app.py flask run
1
docker build -t Dockerfile cozyfex/my-custom-app

Second Dockerfile

1
2
3
4
5
6
7
8
9
FROM ubuntu

RUN apt-get update && apt-get -y install python

RUN pip install flask flask-mysql

COPY app2.py /opt/source-code

ENTRYPOINT FLASK_APP=/opt/source-code/app2.py flask run
1
docker build -t Dockerfile cozyfex/my-custom-app2

Run Container

Image Layers(Read Only Layer)

1
docker build -t Dockerfile cozyfex/my-custom-app

Container Layer(Read Write Layer)

1
docker run cozyfex/my-custom-app

Exit Container

IMPORTANT
After exit container, there’s no file remain.

Volumes

Create a Volume

1
docker volume create data_volume
1
2
3
4
5
6
/var/lib/docker
├── aufs
├── containers
├── image
├── volumes
│   ├── data_volume
1
docker run -v data_volume:/var/lib/mysql mysql
1
docker run -v /data/mysql:/var/lib/mysql mysql
1
docker run --mount type=bind,source=/data/mysql,target=/var/lib/mysql mysql

Docker Storage

Storage Drivers

Volume Drivers

  • Local
  • Azure File Storage
  • Convoy
  • DigitalOcean Block Storage
  • Flocker
  • gce-docker
  • GlusterFS
  • NetApp
  • RexRay
  • Portworx
  • VMWare vShpere Storage

Volume Mount

1
2
3
4
5
docker run -it \
  --name mysql
  --volume-driver rexray/ebs
  --mount src=ebs-vol,target=/var/lib/mysql
  mysql

Container Structure

CRI(Container Runtime Interface)

CSI(Container Storage Interface)

CNI(Container Network Interface)