简体   繁体   English

如何调整我的 docker 设置,以便 localstack 文件存储在系统重启之间持续存在?

[英]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:代表着:

  • You need a Pro subscription to enable persistence (with which you'll get an API Key).您需要Pro 订阅才能启用持久性(您将获得 API 密钥)。 Without it, setting PERSISTENCE=1 will NOT enable persistence.没有它,设置PERSISTENCE=1将不会启用持久性。
  • Once you have your Pro subscription (and API Key), you can use a Docker Compose config such as:获得 Pro 订阅(和 API 密钥)后,您可以使用 Docker Compose 配置,例如:
    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.

相关问题 如何在Docker容器之间建立链接,以便重新启动不会破坏它? - How do I set up linkage between Docker containers so that restarting won't break it? 如何在 WSL + VS Code 和 Docker 容器之间设置文件所有权? - How do I set-up file ownership between WSL + VS Code and a Docker container? 如何在加载后对我的 localstack Docker 容器执行 shell 脚本? - How do I execute a shell script against my localstack Docker container after it loads? 如何设置远程docker以便我可以远程运行docker命令而无需在主机上安装docker - How to set up remote docker so that i can run docker command remotely without installing docker on my host 如何设置PhpStorm,以便Docker Compose Interpreter可以使用PHP可执行文件? - How do I set up PhpStorm so that the Docker Compose Interpreter can use the PHP executable? 如何调整我的 Apache Docker 配置以仅将一些 URL 路由到我的 Docker django 实例? - How do I adjust my Apache Docker config to only route some URLs to my Docker django instance? 为什么 docker 在我的 mac 中占用了这么多存储空间 - Why docker is taking up so much storage in my mac 如何设置docker日期并确保其不与我的系统时间同步? - How do I set docker date and ensure that it does NOT sync with my system time? 如何正确设置 Keystone.js 应用程序以在 docker 中使用 mongo 运行? - How do I properly set up my Keystone.js app to run in docker with mongo? 在我的 Apache Docker 容器中,如何设置代理来路由其他代理未处理的所有内容? - In my Apache Docker container, how do I set up a Proxy to route everything not handled by other proxys?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM