Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DawnBreather/0e2fa3f24d32fc1f7ec2ad17a9b6d11b to your computer and use it in GitHub Desktop.
Save DawnBreather/0e2fa3f24d32fc1f7ec2ad17a9b6d11b to your computer and use it in GitHub Desktop.
wiki.docker

Mounting Amazon S3 Bucket in Windows and Docker

1. Introduction

This document provides a comprehensive guide on how to mount an Amazon S3 bucket as a directory in Windows using Rclone, and how to subsequently mount this directory into a Docker container as a volume.

2. Prerequisites

  • An Amazon Web Services (AWS) account.

  • An S3 bucket created in your AWS account.

  • Windows operating system.

  • Docker Desktop installed on your Windows system.

3. Mounting S3 Bucket as a Directory in Windows

3.1. Step 1: Install Rclone

  1. Download Rclone from https://rclone.org/downloads/.

  2. Unzip the downloaded file and install Rclone following the instructions on the website.

3.2. Step 2: Configure Rclone with Amazon S3

  1. Open a Command Prompt window as an administrator.

  2. Run rclone config to start the configuration process.

  3. Follow the prompts to create a new remote, select Amazon S3 as the storage type, and enter your AWS Access Key ID, Secret Access Key, and region.

3.3. Step 3: Mount the S3 Bucket

  1. Install WinFsp from https://github.com/billziss-gh/winfsp/releases to support mounting.

  2. Use the command rclone mount yourRemoteName:bucketName path/to/mount --vfs-cache-mode full to mount the S3 bucket. Replace yourRemoteName with the name you gave your remote, and path/to/mount with your desired mount point.

4. Mounting the Directory into a Docker Container

4.1. Step 1: Ensure the S3 Bucket is Mounted

Ensure your S3 bucket is mounted on your Windows system using Rclone.

4.2. Step 2: Docker Volume Mounting

Use the Docker -v or --mount flag to mount the directory when running your container.

4.3. Step 3: Mount the S3 Directory into the Docker Container

Use the command docker run -v Z:/path/in/container:rw my_image or docker run --mount type=bind,source=Z:/,target=/path/in/container my_image, replacing /path/in/container with the container path and my_image with your Docker image name.

5. Important Considerations

  • Permissions issues might require adjustments in Docker for Windows settings.

  • Performance may be affected due to the network-mounted drive.

  • Ensure Docker and the command prompt are run as an administrator for certain operations.

6. Conclusion

By following these guidelines, you can access S3 bucket data within a Docker container, facilitating a wide range of applications and services.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment