I am new with localstack I copied the docker-compose example. I made sure to mount the data path into my machine,and I do see it in host tmp folder,In addition I see my data being append when calling s3 write commands, but after I kill the docker-compose and start it from scratch I don't see the data from the previous session. Is there a special flag that I need to add to reload the data?
docker-compose file:
version: '3.0'
services:
localstack:
image: localstack/localstack:latest
environment:
- AWS_DEFAULT_REGION=us-east-1
- EDGE_PORT=4566
- SERVICES=sqs,sns,s3
- DATA_DIR=/tmp/localstack/data
ports:
- '4566-4583:4566-4583'
volumes:
- "/tmp/localstack:/tmp/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
Example run:
aws --endpoint-url=http://localhost:4566 s3 mb s3://bucket-test
aws --endpoint-url=http://localhost:4566 s3 cp myfile.png s3://bucket-test
#Now this command will return the file
aws --endpoint-url=http://localhost:4566 s3 ls s3://bucket-test
# But after I will kill the docker and run docker-compose up again I will see nothing
Your data will be deleted by running docker-compose down. This stops and removes your containers: https://docs.docker.com/compose/reference/down/
To stop the containers without deleting the volumes, run: docker-compose stop
I was able to keep data related to my ssm parameters by adding "DATA_DIR" and the following volumes :
- "/tmp/localstack:/tmp/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"
My docker-compose.yml file looks like :
version: '3.0'
services:
localstack:
build: ./localstack
container_name: localstack
environment:
- SERVICES=${LOCALSTACK_SERVICES:-ssm,cloudwatch,cloudformation}
- DATA_DIR=${LOCALSTACK_DATA_DIR:-/tmp/localstack/data}
- AWS_DEFAULT_REGION=us-west-2
- EDGE_PORT=4566
- LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY}
volumes:
- ./localstack/bootstrap:/opt/bootstrap/
- ./data:/tmp/localstack
- "/var/run/docker.sock:/var/run/docker.sock"
ports:
- '4566:4566'
- '443:443'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With