Shashikant shah

Wednesday 16 September 2020

Docker Storage commands part-5

 

Docker Storage commands :-

There are three main ways to manage data in containers:

·       Data volumes

·       Mount the host directory (bind mounts)

·       tmpfs for caching memory



·       Data volumes :- Volumes are stored in a part of the host filesystem which is managed by Docker (/var/lib/docker/volumes/ on Linux). Volumes are the best way to persist data in Docker.

·       Mount the host directory (bind mounts) :- Bind mounts may be stored anywhere on the host system.

·       tmpfs :- tmpfs mounts are stored in the host system’s memory only.

 

  1. volume lists.

# docker volume ls

  1. bind mount.

# docker container run -it -v /home/ubuntu/test:/tmp/test ubuntu:14.04 bash

  1. create a volume .

# docker volume create <volume_name>

# docker container run -it -v <volume_name>:/tmp/test ubuntu:14.04 bash

  1. volume details.

# docker volume inspect <volume_name>

  1. remove volume.

# docker volume rm <volume_name>

     6. change to docker home directory:-

        # vim /etc/sysconfig/docker-storage

            DOCKER_STORAGE_OPTIONS=

    7. Number of files open in container.

        #vim /etc/sysconfig/docker

        DAEMON_MAXFILES=1048576
       OPTIONS="--default-ulimit nofile=1024:4096"


8. Volume mount other location use local-persist plugin :-
 # docker info

Plugins:

  Volume: local local-persist

  Network: bridge host ipvlan macvlan null overlay

  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog

# docker volume create -d local-persist -o mountpoint=/mnt/ --name=shashi_extra

# docker container  run -it -v shashi_extra:/tmp/test ubuntu:14.04 bash

ref link :- https://unix.stackexchange.com/questions/439106/docker-create-a-persistent-volume-in-a-specific-directory

No comments:

Post a Comment