New to Docker, and moving on to docker compose. In the past I would start up a container with: docker run -v /localFolder:/containerFolder containerName
I am trying to do the same in a docker-compose.yml, or even in Dockerfile.
New to Docker, and moving on to docker compose. In the past I would start up a container with: docker run -v /localFolder:/containerFolder containerName
I am trying to do the same in a docker-compose.yml, or even in Dockerfile.
Use volumes
volumes:
# Just specify a path and let the Engine create a volume
- /var/lib/mysql
# Specify an absolute path mapping
- /opt/data:/var/lib/mysql
# Path on the host, relative to the Compose file
- ./cache:/tmp/cache
# User-relative path
- ~/configs:/etc/configs/:ro
# Named volume
- datavolume:/var/lib/mysql
See also detailed post: Use volumes
This is the way to persist the data in volume to the instance
services:
redis:
volumes:
- '_data:/var/lib/data'
volumes:
_data:
driver: local