I have this docker-compose.yml file with a localstack image that i use to simulate S3 storage
version: '3.8'
services:
localstack:
image: localstack/localstack:latest
environment:
- DEFAULT_REGION=ap-northeast-1
- EDGE_PORT=4566
- SERVICES=s3,logs
- AWS_DEFAULT_REGION=us-west-1
- AWS_ACCESS_KEY_ID=xxx
- AWS_SECRET_ACCESS_KEY=xxx
- DOCKER_HOST=unix:///var/run/docker.sock
- DATA_DIR=/tmp/localstack/data
ports:
- '4566-4583:4566-4583'
volumes:
- ./make_bucket.sh:/docker-entrypoint-initaws.d/make_bucket.sh
The "make_bucket.sh" script consists of
aws --endpoint-url=http://localhost:4566 s3 mb s3://my-bucket
When I run "docker-compose up," everything runs fine, and I am able to upload files into my bucket, but when I stop my container (using Ctrl + C for instance) and then restart it later, or when my system blue screens (because it is Windows) and I restart, my volumes have been destroyed and my images are no longer present. Is there a way I can configure my docker-compose file so that my files persist between restarts?
Edit: I’m not wed to using localstack — if I had any imaeg that could mimic S3 storage and could persist data across restarts I’d be happy.
2
Answers
DATA_DIR
has been deprecated with LocalStack v1.0.0. Simply settingPERSISTENCE=1
as your environment variable should enable persistence.However, keep in mind that persistence is a Pro-only feature.
If you are interested, Cloud Pods now offer all users the possibility to snapshot the instance state and restore it at will. Check out more here.
Persistence is documented here, it specifies:
it means that:
PERSISTENCE=1
will NOT enable persistence.