How does S3_MOUNT work?

I have set this env var to no avail. In the docs it says:
Configure a global parent directory that contains all buckets as sub-directories

What does this mean? I take it to mean that I can configure a directory that localstack will use to store all created S3 buckets as directories. This does not work in practice. I’m using Localstack as a docker container. I have a pro license.

What I really need to do is to mount all of the buckets I create back to my host machine. I want to be able to see all uploaded files mounted to the host, or have some other way to visually browse S3 files on Localstack. The pro app in the browser doesn’t really work, it doesn’t list any S3 objects that exist in directories/keys only files that are present at the top level of a bucket.

Any help or tips would be really appreciated.

Hi!
I am sorry for your inconvenience, but the docs are wrong for this variable.
The real name is S3_DIR, not S3_MOUNT. I will correct it immediately.
In general, the usage in a docker compose file would be like this:

version: "3.8"

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack
    ports:
      - "127.0.0.1:4566:4566"            # LocalStack Gateway
      - "127.0.0.1:4510-4559:4510-4559"  # external services port range
      - "127.0.0.1:53:53"                # DNS config (only required for Pro)
      - "127.0.0.1:53:53/udp"            # DNS config (only required for Pro)
      - "127.0.0.1:443:443"              # LocalStack HTTPS Gateway (only required for Pro)
    environment:
      - DEBUG=${DEBUG-}
      - PERSISTENCE=${PERSISTENCE-}
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR-}
      - LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY-}  # only required for Pro
      - DOCKER_HOST=unix:///var/run/docker.sock
      - S3_DIR=/tmp/s3-mounts
    volumes:
      - "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
      - "./mounts:/tmp/s3-mounts"
      - "/var/run/docker.sock:/var/run/docker.sock"

So you have to mount a folder from your host to the location S3_DIR specifies, then it should work like advertised.
While testing this functionality, I found some problems with multi-part upload while using this feature, I will put in an internal bug report for this.

2 Likes