Mount ebs volume in image build

I have been struggling for a couple days trying to mount an ebs volume inside an image, so upon building it the data is accessible. I do have the volume /data mounted in the ec2 and can see all the folders/files in it, I can also see the /data in the container after the image is built, however the folders/files in /data are not there. Thank you :).

Dockerfile

FROM alpine:3.13.5

WORKDIR /path/to

USER root

VOLUME /data

COPY /data/* /data

contents of /data

folder1
file1
file2
file3

folder2
file1
file2

Normally you must map and expose all ports in a docker image, exposing them to the host

Often people forget this critical step when working with Docker images.

Please check this.

1 Like