Quantcast
Channel: Active questions tagged dockerfile - DevOps Stack Exchange
Viewing all articles
Browse latest Browse all 136

How do I test data persistence with a simple counter applicaiton in javascript?

$
0
0

I've a basic counter application in javascript.

var count=0;function counter(){    count++;    console.log(count);}counter();

I want to test persistence of data using volumes and bind mount in docker.

How do I do it?

I'm aware of syntax for volumes, but I didn't get exactly what I should do here.

What I've tried?

  1. Create a Dockerfile

    COPY index.html /usr/share/nginx/htmlCOPY script.js /usr/share/nginx/html
  2. Build the image using

    docker build -t my-counter-app .

Image named my-counter-app has been built.

  1. Start and Run the container using volumes

    docker run -it -d -p 80:80 -v demo_volume:/data my-counter-app

  2. Stop and remove the container

    docker stop <container-id>docker rm <container-id>

  3. Again start and run the container

    docker run -it -d -p 80:80 -v demo_volume:/data my-counter-app

My expected output is that the counter should begin with last recorded value.

How do I achieve this? I don't want to use docker compose or any additional things.


Viewing all articles
Browse latest Browse all 136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>