我一直在使用 localstack 来开发针对本地的服务。我刚刚通过运行他们的 docker 镜像docker run --rm -p 4567-4583:4567-4583 -p 8080:8080 localstack/localstack
然后我手动运行一个小脚本来设置我的 S3 存储桶、SQS 队列等。
现在,我想让其他人更容易做到这一点,所以我想我只需添加一个 Dockerfile 和 docker-compose.yml 文件。不幸的是,当我尝试启动并运行它时,docker-compose up
我收到一个错误,即我的安装脚本中的命令无法连接到 localstack 服务。
make_bucket failed: s3://localbucket Could not connect to the endpoint URL: "http://localhost:4572/localbucket"
Dockerfile:
FROM localstack/localstack
#since this is just local dev set up, localstack doesn't require
anything specific here.
ENV AWS_DEFAULT_REGION='[useast1]'
ENV AWS_ACCESS_KEY_ID='[lloyd]'
ENV AWS_SECRET_ACCESS_KEY='[christmas]'
COPY bin/localSetup.sh /localSetup.sh
COPY fixtures/notifications.json /notifications.json
RUN ["chmod", "+x", "/localSetup.sh"]
RUN pip install awscli
# expose service & web dashboard ports
EXPOSE 4567-4582 8080
ENTRYPOINT ["/localSetup.sh"]
码头工人-compose.yml
version: '3'
services:
localstack:
build: .
ports:
- "8080:8080"
- "4567-4582:4567-4582"
localSetup.sh
#!/bin/bash
aws --endpoint-url=http://localhost:4572 s3 mb s3://localbucket
#additional similar calls but left off for brevity
我尝试在我的脚本命令中切换localhost
到127.0.0.1
,但我最终遇到了同样的错误。我可能在这里遗漏了一些愚蠢的东西。