satyam.kudikala
satyam.kudikala

Reputation: 99

Adding s3 bucket as docker volume

I have one spring boot application which is in our internal data center, which process files from a specific folder on the host.

we wanted to deploy this to aws and wanted to use s3 bucket to upload files for processing.

is there any way we can add s3 bucket space as docker volume?

Upvotes: 9

Views: 30714

Answers (3)

Alexey Kamenskiy
Alexey Kamenskiy

Reputation: 2948

UPD: See at the bottom of this answer.

Other answers mistakenly say that AWS S3 is an object store and you can not mount it as volume to docker. Which is not correct. AWS S3 has a 3rd party FUSE driver, which allows it to be mounted as local filesystem and operate on objects as if those were files.

However it does not seem this FUSE driver has been made available as storage plugin for Docker just yet.

Edit: well, i have to correct myself after just a couple of minutes posting this. There in fact is a FUSE based driver for Docker to get volume mounted from AWS S3. See REX-ray and also here for possible configuration issue.

Upvotes: 10

Utsav Chokshi
Utsav Chokshi

Reputation: 1395

Other answers have correctly pointed out that : AWS S3 is an object store and you can not mount it as volume to docker.

That being said, using S3 with spring application is super easy and there is framework developed called spring-cloud. spring-cloud works excellent with AWS.

Here is sample code :

public void uploadFiles(File file, String s3Url) throws IOException {
   WritableResource resource = (WritableResource) resourceLoader.getResource(s3Url);

   try (OutputStream outputStream = resource.getOutputStream()) {
       Files.copy(file.toPath(), outputStream);
   }
}

You can find detailed blog over here.

Upvotes: 1

Banjo Obayomi
Banjo Obayomi

Reputation: 1690

No docker volume is for mounting drives on the machine (https://docs.docker.com/storage/volumes/)

You can use the S3 api to manage your bucket from the docker container (https://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html)

Upvotes: -1

Related Questions