localstack Kinesis无法在docker中启动

时间:2019-09-24 22:37:53

标签: amazon-kinesis localstack

我们在Windows 10上运行Docker。我们有一个简单的Java Springboot应用程序,该应用程序应与AWS Kinesis和S3交互。对于本地测试,我们要提取本地堆栈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安装:

$ 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

任何指针将不胜感激

2 个答案:

答案 0 :(得分:2)

因此,我正在尝试验证(提供强有力的证据)答案,但显然默认的 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'

希望有帮助

答案 1 :(得分:1)

我认为这可能是格式化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'

希望这会有所帮助