Creating data containers in Docker

Creating data containers in Docker

1.Create a Data Container for storing configuration files

to create data containers in docker we need a base image and path for saving data

syntax

docker create -v <path to savedata> --name containename <baseimage>

example

docker create -v /config --name dataContainer busybox

2.Copy config files to container

to copy files from our local directory to container directory

syntax

docker cp config.conf <containername>:<path>

example

docker cp config.conf dataContainer:/config/

3.Mount Volumes

we can use mount values from other containers inside the container being launched

syntax

docker run --volumes-from <conatinername> <baseimage> ls /config

3)

docker run --volumes-from dataContainer ubuntu ls /config

4.export and import containers

syntax

docker export Containername > filename.tar

4)

docker export dataContainer > dataContainer.tar

syntax

for importing container

docker import filename.tar
Last updated on by vishal devxo