Alon
Alon

Reputation: 11885

Failed to use volumes

I am trying to use volumes.

I created an app that reads from and writes to a file.

Either if I run it like that (without a volume):

docker run -p 3000:3000 hello-express

or if I run it like that (with a volume):

docker run -p 3000:3000 -v myvol:/myvol hello-express

I get the same result: the data is persisted after I stop and start the contianer, but it's deleted after I remove the container and run it again.

So something is wrong here.

Upvotes: 0

Views: 49

Answers (1)

Farrukh Faizy
Farrukh Faizy

Reputation: 1235

You can try to create the Volume in DockerFile and attach it while running the command with the container you want. As volume are isolated with container and they have no dependency to the specific container. You can refer to this good article of volumes as well. Hope it helps.

Upvotes: 1

Related Questions