Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add s3 files to docker image

I am a newbie to docker. I am trying to deploy a R app as a docker image. I am able to deploy the app in docker by mounting the folder. But I don't think that is going to work in AWS. I am thinking of storing my app in s3 and adding it during the build by ADD command. But it is throwing me this error : ADD failed: stat /var/lib/docker/tmp/docker-builder441270805/s3:/bucket_name/app: no such file or directory

Can you guys please give me any idea on how to do it ? Thanks

like image 467
Aromadz Avatar asked Aug 16 '17 13:08

Aromadz


People also ask

Can I push Docker image to S3?

Once the image is tagged we are good to push. Using the docker push command let's push the image. We are successfully able to push image to registry running on kunbernetes and stored on S3.

Can we use the S3 bucket as a Docker registry?

We are using an S3 bucket as docker registry. If we want to use it in an instance or on premise server, we setup registry & then use it.

Is S3 good for images?

The more efficient and cost-effective option is to use AWS's S3 service for storing the image files. Using S3 is a very low-cost option. Effectively, all you are paying for is transferring files into an S3 bucket and serving those images to your users.

Can Amazon S3 store images?

You can have an unlimited number of objects in a bucket. Before you can upload files to an Amazon S3 bucket, you need write permissions for the bucket. For more information about access permissions, see Identity and access management in Amazon S3. You can upload any file type—images, backups, data, movies, etc.


1 Answers

This doesn't work because /var/lib/docker/tmp/docker-builder441270805/s3:/bucket_name/app is not a valid path, docker simply can't find anything there.

Possible solutions:

  1. mount the s3 folder to a local folder and use that instead.
  2. Make the bucket publically available and download the app in the Dockerfile using curl/wget or whatever.

Option 1 has the advantage of having to change very little to your current workflow while option 2 would allow anyone with access to the bucket to be able to build the dockerfile without having to do anything to the underlying os / file structure.

Note downloading the files from s3 might not always work, the docker cache is rather aggressive and may cause issues when you want the updated output to make it into a new container.

For more info see this blog post.

like image 131
Rick van Lieshout Avatar answered Oct 20 '22 05:10

Rick van Lieshout