Configuring a local S3 environment with Docker can be useful for development and testing. Here's how to do it:
First, create a docker-compose.yml
file with the following content:
version: '3.7'
services:
s3:
image: localstack/localstack:0.12.5
container_name: bucket_s3
environment:
- SERVICES=s3
- DEBUG=1
- DEFAULT_REGION=${AWS_DEFAULT_REGION}
- AWS_ACCESS_KEY=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ports:
- '4566:4566'
volumes:
- '../s3-storage/.localstack:/tmp/localstack'
Next, run the following command in the terminal to create the S3 bucket:
aws --endpoint-url=http://localhost:4566 s3 mb s3://my-bucket-name
Jorge García
Fullstack developer