I am trying to build an Amazon AMI that contains docker running as a daemon, runs a particular image with a mounted volume from the host, and installs some software and data inside the docker image (which will land in the mounted volume). I'd like the resulting AMI to run the same docker image on startup with the same mounted volume. The goal is to build an EC2 image that uses a pre-built docker image that other users could use outside EC2 to do the same installation process to enable non-Amazon users to reproduce the process. The AMI piece is to facilitate a group of users to have a simple user experience.
I have used Packer in the past for something similar (https://github.com/seandavi/terraform-can/tree/master/packer), but I'd like to introduce the docker piece and am not clear on the approach to take. Any examples or pointers are appreciated, but the process seems like:
Inside packer build:
- install docker engine
- run docker image with mounted volume
- docker exec into the image to install software and data to mounted volume
How do I set up the AMI via packer to run the same image with mounted volume at startup of the AMI after build?
docker execvery much likessh root@your EC2 instance: you can, and it's really useful to debug, but it's not the default way to do things. - David Maze