0

我有一个 docker compose 文件,如下所示:

version: "3"

services:
  localstack:
    image: localstack/localstack:latest
    ports:
      - "4567-4597:4567-4597"
      - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=s3
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/private${TMPDIR}:/tmp/localstack"
    networks:
      - my_awesome_network

  setup-resources:
    image: mesosphere/aws-cli
    volumes:
      - ./dev_env:/project/dev_env
    environment:
      - AWS_ACCESS_KEY_ID=dummyaccess
      - AWS_SECRET_ACCESS_KEY=dummysecret
      - AWS_DEFAULT_REGION=us-east-1
    entrypoint: /bin/sh -c
    command: >
      "
        sleep 10;
        # aws kinesis create-stream --endpoint-url=http://localstack:4568 --stream-name my_stream --shard-count 1;
        aws --endpoint-url=http://localhost:4572 s3 mb s3://demo-bucket
      "
    networks:
      - my_awesome_network
    depends_on:
      - localstack
networks:
  my_awesome_network:

从我发现的这篇博客文章中复制了它,但是当我运行docker-compose up存储桶时无法创建并出现以下错误:('Connection aborted.', error(99, 'Address not available'))

4

3 回答 3

3

我用小改动运行它并且它工作正常,将 localhost 更改为 localstack

version: "3"

services:
  localstack:
    image: localstack/localstack:latest
    ports:
      - '4568-4576:4568-4576'
      - '8055:8080'
    environment:
      - SERVICES=s3
      - DOCKER_HOST=unix:///var/run/docker.sock
      - DEFAULT_REGION=us-east-1
      - DEBUG=1
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/private${TMPDIR}:/tmp/localstack"
    networks:
      - my_awesome_network

  setup-resources:
    image: mesosphere/aws-cli
    volumes:
      - ./dev_env:/project/dev_env
    environment:
      - AWS_ACCESS_KEY_ID=dummyaccess
      - AWS_SECRET_ACCESS_KEY=dummysecret
      - AWS_DEFAULT_REGION=us-east-1
    entrypoint: /bin/sh -c
    command: >
      "
        sleep 10;

        aws --endpoint-url=http://localstack:4572 s3 mb s3://demo-bucket
      "
    networks:
      - my_awesome_network
    depends_on:
      - localstack
networks:
  my_awesome_network:
于 2020-05-21T18:43:29.053 回答
0

这里的小细节,但它不应该是aws --endpoint-url=http://localhost:4572 s3 mb s3://demo-bucket 它应该是aws --endpoint-url=http://localstack:4572 s3 mb s3://demo-bucket,这是正确localhostlocalstack

于 2019-12-18T10:26:11.640 回答
0

从版本 0.11.0 开始,所有 API 都通过单个边缘服务公开,可在

http://localhost:4566 by default

和 EDGE_PORT=4566。

在这篇 文章中找到

于 2020-12-02T13:54:47.057 回答