3

我们在 Windows 10 上运行 Docker。我们有一个简单的 Java Springboot 应用程序,它应该与 AWS Kinesis 和 S3 交互。对于本地测试,我们要拉取 localstack Docker 最新镜像并安装并运行。但是 Kinesis 的启动会引发错误,而 S3 工作正常。以下是详细信息:

docker compose:
version: '3.1'
services:
  localstack:
    image: "localstack/localstack"
    container_name: localstack_demo
    environment:
      SERVICES: kinesis, s3, sqs
      DEBUG: 1
      DATA_DIR: /tmp/localstack
      KINESIS_STREAM_SHARDS: 1
      KINESIS_ERROR_PROBABILITY: 0.0
      KINESIS_STREAM_NAME: my-stream
    ports:
      - "4567-4584:4567-4584"
      - "8055:8080"
    volumes:
      - './.localstack:/tmp/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

当我们尝试点击 Kinesis 的默认 URL 时http://localhost:4568,我们收到以下错误:(请注意,S3 的默认 URL 会按预期响应):

localstack_demo | 2019-09-24T22:35:27:ERROR:localstack.services.generic_proxy: Error forwarding request: the JSON object must be str, bytes or bytearray, not 'NoneType' Traceback (most recent call last):
localstack_demo |   File "/opt/code/localstack/localstack/services/generic_proxy.py", line 240, in forward
localstack_demo |     path=path, data=data, headers=forward_headers)
localstack_demo |   File "/opt/code/localstack/localstack/services/kinesis/kinesis_listener.py", line 22, in forward_request
localstack_demo |     data = json.loads(to_str(data))
localstack_demo |   File "/usr/lib/python3.6/json/__init__.py", line 348, in loads
localstack_demo |     'not {!r}'.format(s.__class__.__name__))
localstack_demo | TypeError: the JSON object must be str, bytes or bytearray, not 'NoneType'

我的码头安装:

$ docker info
Containers: 3
 Running: 2
 Paused: 0
 Stopped: 1
Images: 169
Server Version: 18.09.9
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.14.141-boot2docker
Operating System: Boot2Docker 18.09.9 (TCL 8.2.1)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 989.4 MiB
Name: default
ID: QYOP:66HM:CLYX:77QX:UJES:37LA:JTFL:ER2U:2ZDA:HNNM:JWNN:CBOA
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox
Insecure Registries:
 127.0.0.0/8

任何指针将不胜感激

4

2 回答 2

5

所以,我正在尝试验证(提供强有力的证据)答案,但显然默认的 kinesis 提供程序在我的 Silicon M1 上无法正常工作(如果你知道我的意思的话)。我注意到 kinesis 提供者kinesis-mock,默认的,在启动后立即崩溃......

对我有用的解决方案是使用环境变量切换 kinesis 提供程序:

- KINESIS_PROVIDER=kinesalite

并且配置可能看起来像之前添加的答案:

version: '3.1'
services:
  localstack:
    image: "localstack/localstack"
    container_name: localstack_demo
    environment:
      - SERVICES=kinesis,s3,sqs
      - DEBUG=1
      - DATA_DIR=/tmp/localstack
      - KINESIS_STREAM_SHARDS=1
      - KINESIS_ERROR_PROBABILITY=0.0
      - KINESIS_STREAM_NAME=my-stream
      - KINESIS_PROVIDER=kinesalite
    ports:
      - "4567-4584:4567-4584"
      - "8055:8080"
    volumes:
      - './.localstack:/tmp/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

希望它有所帮助

于 2021-07-29T06:53:59.830 回答
4

我认为这可能是您格式化 docker compose YAML 文件的方式,这是您在此处尝试实现的可能修复:

version: '3.1'
services:
  localstack:
    image: "localstack/localstack"
    container_name: localstack_demo
    environment:
      - SERVICES=kinesis,s3,sqs
      - DEBUG=1
      - DATA_DIR=/tmp/localstack
      - KINESIS_STREAM_SHARDS=1
      - KINESIS_ERROR_PROBABILITY=0.0
      - KINESIS_STREAM_NAME=my-stream
    ports:
      - "4567-4584:4567-4584"
      - "8055:8080"
    volumes:
      - './.localstack:/tmp/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

希望这可以帮助

于 2019-11-20T16:17:10.513 回答