Search code examples
amazon-s3docker-composeaws-serverlesslocalstack

Running localstack with docker-compose


I'm running localstack setup with docker-compose.yaml and below is the content of docker-compose.yaml

version: "3.8"
services:
   localstack:
     image: localstack/localstack:latest
     container_name: localstack_test
     ports:
       - "127.0.0.1:4566:4566"
       - "127.0.0.1:4463-4499:4463-4499"
     environment:
       - SERVICES=s3
       - DEBUG=1
       - DATA_DIR=/tmp/localstack/data
     volumes:
       - "./.localstack:/var/lib/localstack"
       - "/var/run/docker.sock:/var/run/docker.sock"

Whenever we try to hit the URL localhost:4566, it returns a blank page in browser and the docker logs are as below.

localstack    | 2023-02-08T13:06:25.695 DEBUG --- [  MainThread] plugin.manager             : plugin localstack.hooks.on_infra_ready:extensions_on_infra_ready is disabled
localstack    | 2023-02-08T13:06:25.695 DEBUG --- [  MainThread] plugin.manager             : instantiating plugin PluginSpec(localstack.hooks.on_infra_ready.initialize_health_info = <function initialize_health_info at 0x7fbfdcf48310>)
localstack    | 2023-02-08T13:06:25.695 DEBUG --- [  MainThread] plugin.manager             : plugin localstack.hooks.on_infra_ready:initialize_health_info is disabled
localstack    | 2023-02-08T13:06:34.860 DEBUG --- [   asgi_gw_0] l.aws.handlers.service     : no service set in context, skipping request parsing
localstack    | 2023-02-08T13:06:34.864  INFO --- [   asgi_gw_0] localstack.request.http    : GET / => 200

Can anyone, please let me know what's the issue here ? it was invoking s3 initially without any changes and then restarting docker is causing this. Thanks in advance


Solution

  • The behavior that a call to localhost:4566 would be interpreted as an S3 ListBuckets command was removed with LocalStack 1.0. You can get this behavior by calling instead http://s3.localhost.localstack.cloud:4566. Here's an example:

    awslocal s3 mb s3://foo
    curl s3.localhost.localstack.cloud:4566
    

    will correctly output:

    <ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01"><Owner><ID>bcaf1ffd86f41161ca5fb16fd081034f</ID><DisplayName>webfile</DisplayName></Owner><Buckets><Bucket><Name>foo</Name><CreationDate>2023-02-26T23:34:47.000Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>
    

    and the localstack logs should output:

    2023-02-27T00:34:53.745  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS s3.ListBuckets => 200