title: localstack + docker-compose + S3
body: <p>I got a service in Java with Spring-boot + spring-cloud-aws-messaging ... that uploads files into S3 ...</p>
  <p>It's failing when tries to upload a file into S3 bucket (only when I run it in docker-compose).</p>
  <p>here is my code</p>
  <p>pom.xml</p>
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;spring-cloud-aws-messaging&lt;/artifactId&gt;
      &lt;version&gt;2.2.6.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  <p>S3 client</p>
  <pre><code> public AmazonS3 amazonS3Client() {
          return AmazonS3ClientBuilder
                  .standard()
                  .withEndpointConfiguration(
                          new AwsClientBuilder.EndpointConfiguration(appConfig.getAwsS3Endpoint(), appConfig.getRegion()))
                  .withCredentials(credentialsProvider)
                  .build();
      }
  </code></pre>
  <p>docker-compose yaml</p>
  <pre><code>version: '3.7'
  services:
  
    dumb-service:
      build: ../dumb-service/.
      image: dumb-service:latest
      hostname: dumb-service
      ports:
        - '8080:8080'
        - '5006:5006'
      environment:
        JAVA_OPTS: '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5006' 
        AWS_S3_ENDPOINT: 'http://localstack:4566/'
        AWS_S3_BUCKET: 'dumb-bucket'
        AWS_SQS_ENDPOINT: 'http://localstack:4566'
        PDF_REQUEST_QUEUE_URL: 'http://localstack:4566/000000000000/dumb-inbound.fifo'
        PDF_REQUEST_QUEUE_NAME: 'dumb-inbound.fifo'
        AWS_REGION: &quot;${AWS_REGION}&quot;
        AWS_ACCESS_KEY_ID: &quot;${AWS_ACCESS_KEY_ID}&quot;
        AWS_SECRET_ACCESS_KEY: &quot;${AWS_SECRET_ACCESS_KEY}&quot;
      depends_on:
        - &quot;localstack&quot;
  
    # localstack home: https://github.com/localstack/localstack
    localstack:
      hostname: localstack
      container_name: &quot;${LOCALSTACK_DOCKER_NAME-localstack_main}&quot;
      image: localstack/localstack
      ports:
        - '4566:4566'
        - '4571:4571'
      environment:
        - SERVICES=${SERVICES-}
        - DEBUG=${DEBUG-}
        - DATA_DIR=${DATA_DIR-}
        - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-}
        - HOST_TMP_FOLDER=${TMPDIR:-/tmp/}localstack
        - DOCKER_HOST=unix:///var/run/docker.sock
      volumes:
        - &quot;${TMPDIR:-/tmp}/localstack:/tmp/localstack&quot;
        - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
  
  </code></pre>
  <p>Error is:</p>
  <p><strong>Unable to execute HTTP request: dumb-bucket.localstack</strong></p>
  <p>(This code is working fine with AWS services or running code native + localstack)</p>
  <p>Any thoughts about how to connect to localstack S3 ?</p>