hello,
i have provision aws ec2 instance which is docker host. In that, i have created dockerfile with the copy instruction to get copy of my application from the specified directory . Now i have created another volume in aws ec2 instance and attached with instance (its not partition it is another disk).
how can i attach that volume to the container so next time my container get data from there not by using copying instruction.
Please help
The volume for the ec2 host is mounted?
Mount the volume for the host, you may need to create a file system for your application.
commands for ec2
lsblk (will show the volume path i.e /dev/xvdc)
mkfs.xfs /dev/xvdc
mount /dev/xvdc/ /home/$USER/myapp ( make sure myapp directory exists)
Make sure you update /etc/fstab or the mount will not persist after host restart.
Now the host has an exposed volume.
Copy your application to that volume.
YOu can use a bind-mount(-v) to run your application from the volume.
docker run -v /home/$USER/myapp:/container/path/to/run/app/from …
Let us know iff that was helpful.
Good Luck.!
in my dockerfile i have instruction of copy for my application. if i dont put copy instruction so what should i write in dockerfile for volume.
Drop the copy…
Volume attribute is not required…
hello
how to check that exposed volume and
how to copy of application to that volume
can u please help me in that
After the volume is mounted like I showed above…
df -h
will show tath /dev/xvdc is mounted on /home/$USER/myapp
IFF you can; mount the app directory, do not copy.
OR
cp -r /home/$USER/development/myapp/ /home/$USER/for/docker/myapp