Static Persistent Volumes

Self hosted nfs ( network file system ) that are not dependent on any cloud provider.

Creating a networked file system

File system present somewhere on host machine open on a network.

image.png

Step 1 : Starting NFS ( for testing )

# ssh into EC2 machine
ssh -i ~/.ssh/id_rsa_aws [email protected]
vi docker-compose.yml

docker-compose.yml

version: '3.7' # Docker Compose Version
services: # Define a service named nfs-server
  nfs-server: # Ecah service is a container managed by docker compose
    image: itsthenetwork/nfs-server-alpine:latest # Docker image with NFS Server (system that allows multiple containers to share file over a network )
    privileged: true # Give extra permissions to this container since NFS requires it
    environment:
      SHARED_DIRECTORY: /exports # this dir will be exposed over NFS
    volumes:
      - /home/ubuntu/data:/exports:rw # mount local dir ./data into container at exports with read write permission
    ports:
      - '2049:2049'
    restart: unless-stopped # Restart if docker crashes

mkdir data
sudo docker compose up

This will start networked file system on port 2049. Obviously you can’t visit port 2049 since it not an http request but your file is now exposed via NFS.

image.png