0

I'm looking to see if I can create docker instances for developers on EC2 that will not be erased if for some reason the instance/container itself is shutdown, much like EC2's on-demand instances when they are stopped.

What's the right way to do this? Can I do this on Amazon Elastic Container Service?

I'm experienced with EC2 but a docker newbie.

Thanks!

Update: Just to be clear, I want developers to be able to install their own software onto the containers, using sudo, and that environment be preserved in case of system outage.

8
  • The Docker images you create will always be the same. So this isn't very clear what you really want. I suggest you spend a little time working with Docker first. Jul 7, 2015 at 15:32
  • That's right; I've built the docker images already and that seems fine, and I can use sudo to install software etc. The main thing I want to do is make the containers durable, so that they act more like standard VMs.
    – chrism2671
    Jul 7, 2015 at 16:07
  • I wouldn't use Docker if that's a hard requirement. While you can have persistent storage (data volumes) it can't be the root of the filesystem. Jul 7, 2015 at 16:12
  • Is there an LXC or similar solution that would be more appropriate?
    – chrism2671
    Jul 7, 2015 at 16:25
  • Normal virtual machines? Straight LXC or libvirt-lxc could work as well. It really depends on what you're doing, and you didn't say anything about this. Jul 7, 2015 at 16:27

1 Answer 1

2

I would use Dockerfile or docker compose to create the image for running the container, and then put all the important files which have to be retained even if the docker host is destroyed in a separate volume, say an EBS attached to an instance. When you start a container, you mount the EBS volume and add it as a data volume to the container. All the work the developers do has to be saved on the data volume.

As an example, let us say you attach an EBS volume of /dev/sdb1 to an AWS docker host instance. After formatting it, say you mount it as /code on the docker host instance. When you start a container, you add it as -

docker run -d -P --name web -v /code:/var/www demo/webapp python app.py

Now even if the docker host is gone, the /code data should persist, on the container it is /var/www. All the work has to be done on /code or /var/www on the host or container, respectively. On top of that, you can take a snapshot of it as it is an EBS volume.

2
  • Would it be possible to mount the volume in such a way that developers can install software etc using sudo, and when restoring the container, it would be preserved? That way only 'linux core' would be in the container volume itself.
    – chrism2671
    Jul 9, 2015 at 6:14
  • 2
    Per Docker's recommendations, no software should be directly installed in a container. Place all installation commands in a Dockerfile, so that you can easily restore it by executing the Dockerfile. If not, you will need to regularly commit all the changes made on a container, including installed packages, as a Docker images. Then when you want to restore a container, you just run it from the latest image.
    – Daniel t.
    Jul 11, 2015 at 2:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .