Coder Social home page Coder Social logo

docker-data-persistence's Introduction

Data-Persistence-in-Docker

> Create a Volume

docker volume create testvolume

> List all the volumes present locally

docker volume ls

list volumes

> Run a container with attached volume

Here we are are attaching volume testvolume with a folder named app using nginx:latest image

docker run -d --name voldemo -v testvolume:/app nginx:latest

container run command Check running container

> Let's connect to our container using bash

docker exec -it voldemo bash

> Let's create a file in app folder using nano

apt update
apt install nano
cd app
nano test.txt

Once the nano editor opens up, add the below content or whatever you want

Hello World! Welcome to the test file!! 

Now save the file using ctrl+x then press y and Enter

Container bash

> Now Stop and Remove the nginx container

docker stop voldemo
docker rm voldemo

Stopping and Removing cotnainer

Check running container

> Now run the container again and see whether the data still exists or not

docker run -d --name voldemo -v testvolume:/app nginx:latest

> Let's connect to our container using bash

Again, check if the data still exists or not

docker exec -it voldemo bash
ls
cd app
cat test.txt

All again process

docker-data-persistence's People

Contributors

jatinkc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.