I have a docker-compose.yml like this:
version: '2' services: app: build: . volumes: - /usr/src/app If I do docker-compose up, then any changes I make to the /usr/src/app are persisted across runs. I can control+C and then docker-compose up, and the contents are still there.
But if I do docker-compose run app ls -la /usr/src/app, then the path is always empty.
My goal is that I'd like to have that volume 1) automatically created on the fly for me, 2) specific to this docker-compose project (since I'll have many others), and 3) persist across docker-compose up/run/etc.
I think one way around this is to use named volumes, which will automatically pull the name of my docker-compose project.
But with on-the-fly containers, is this the expected behavior? They persist automatically for docker-compose up, and are recreated from scratch for each docker-compose run?
Also, is there any documentation that makes clear the lifetime of on-the-fly containers?
Thanks!
Related questions 420 How to get docker-compose to always re-create containers from fresh images? 7 Docker compose reusing volumes 0 What happens to docker volumes created by container when the container is stopped Related questions 420 How to get docker-compose to always re-create containers from fresh images? 7 Docker compose reusing volumes 0 What happens to docker volumes created by container when the container is stopped 0 docker-compose volumes: When are they mounted in the container? 6 Why does `docker-compose up` erase volumes? 0 when does docker-compose use currently built images and when does it remake the local image? 1 when is docker volume available using docker compose? 1 My confusion in docker volume usage in practice 4 How does "volumes" override the docker image's original files with docker-compose? 0 What does volumes do in docker-compose Load 7 more related questions Show fewer related questions
Reset to default