Answer the question
In order to leave comments, you need to log in
Why doesn't docker save db data to a folder on the host machine?
There is such a piece from docker-compose
db:
hostname: postgres
container_name: postgres
image: postgres:10.1
restart: always
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
ports:
- "5432:5432"
volumes:
- ./.docker/conf/postgres/:/docker-entrypoint-initdb.d/
- ./.docker/conf/postgres/data:/var/lib/postgresql/data
networks:
- backend
Answer the question
In order to leave comments, you need to log in
You need to use volumes at the compose file level . Also, read about named volume .
Delete the db container docker-compose rm db
and then run again docker-compose up
.
When a new container is created (from the image cache), docker will forward the folder from the container to the host.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question