[英]How do I adjust my docker set up so that localstack file storage persists between system restarts?
I have this docker-compose.yml file with a localstack image that i use to simulate S3 storage我有这个 docker-compose.yml 文件和我用来模拟 S3 存储的 localstack 图像
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 “make_bucket.sh”脚本包括
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.当我运行“docker-compose up”时,一切运行正常,我可以将文件上传到我的存储桶中,但是当我停止我的容器(例如使用 Ctrl + C)然后稍后重新启动它时,或者当我的系统蓝色时屏幕(因为它是 Windows)并重新启动,我的卷已被销毁并且我的图像不再存在。 Is there a way I can configure my docker-compose file so that my files persist between restarts?有没有一种方法可以配置我的 docker-compose 文件,以便我的文件在重新启动之间保持不变?
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.编辑:我不习惯使用 localstack——如果我有任何可以模仿 S3 存储并且可以在重新启动时保留数据的 imaeg,我会很高兴。
DATA_DIR
has been deprecated with LocalStack v1.0.0 . DATA_DIR
已在 LocalStack v1.0.0中弃用。 Simply setting PERSISTENCE=1
as your environment variable should enable persistence.只需将PERSISTENCE=1
设置为环境变量即可启用持久性。
However, keep in mind that persistence is a Pro-only feature.但是,请记住持久性是 Pro-only 功能。 If you are interested, Cloud Pods now offer all users the possibility to snapshot the instance state and restore it at will.如果您有兴趣,Cloud Pods 现在为所有用户提供了快照实例 state 并随意恢复它的可能性。 Check out more here . 在这里查看更多。
Persistence isdocumented here , it specifies:持久性在此处记录,它指定:
To enable the persistence mechanism simply set the PERSISTENCE environment variable to 1要启用持久性机制,只需将 PERSISTENCE 环境变量设置为 1
Note that persistence is a Pro feature, therefore the LOCALSTACK_API_KEY must also be set.请注意,持久性是 Pro 的一项功能,因此还必须设置 LOCALSTACK_API_KEY。
it means that:代表着:
PERSISTENCE=1
will NOT enable persistence.没有它,设置PERSISTENCE=1
将不会启用持久性。 environment:
# Persistence needs Pro sub with API Key
- LOCALSTACK_API_KEY=YourApiKey
- PERSISTENCE=1
volumes:
- localstack-data:/var/lib/localstack"
volumes:
localstack-data: {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.