4

I have a Java EE packaged as war file stored in an AWS s3 bucket. I will like to mount the folder containing the .war file as a point in my docker container. I have managed to do this on my local machine. Below is an example of a JBoss wildfly deployments. How can I use s3 for this ?

docker container run -d —name Application -p 8080:8080 -v `pwd` /Application.war: /opt/jboss/wildfly/standalone/deployments/Application.war jboss/wildlfly

  • 1
    Worth checking https://stackoverflow.com/questions/49379881/mount-s3fs-as-docker-volume (but really, you shouldn't do that in my opinion as it breaks the idea of repeatable self contained artifact of docker containers) – Tensibai Jul 17 '19 at 14:02
  • @Tensibai Agreed. Could you indicate why you do not bake the war inside the docker image? The docker image should be immutable. – 030 Jul 17 '19 at 18:50
  • @030 opposite, I would copy the war in the container at build time, not have a container relying on external source by taking the war at runtime as asked – Tensibai Jul 17 '19 at 22:12

4 Answers4

4

Yes , you can ( and in swarm mode you should )

Bash Stack
  • 141
  • 2
3

No you can't.

S3 is an object storage, accessed over HTTP or REST for example. Just as you can't mount an HTTP address as a directory you can't mount a S3 bucket as a directory.

Having said that there are some workarounds that expose S3 as a filesystem - e.g. 's3fs' project. How reliable and stable they are I don't know.

MLu
  • 1,001
  • 5
  • 6
2

Actually, you can use Fuse (eluded to by the answer above).

S3FS-FUSE: This is a free, open-source FUSE plugin and an easy-to-use utility which supports major Linux distributions & MacOS. S3FS also takes care of caching files locally to improve performance. This plugin simply shows the Amazon S3 bucket as a drive on your system.

https://tecadmin.net/mount-s3-bucket-centosrhel-ubuntu-using-s3fs/

I haven't used it in AWS yet, though I'll be trying it soon. There is a similar solution for Azure blob storage and it worked well, so I'm optimistic.

John Humphreys
  • 1,510
  • 5
  • 16
0

Yes, you can. Use Storage Gateway service. It will give you a NFS endpoint. Mount that using kubernetes volumn. It is possible. I have already achieved this.

again
  • 189
  • 5