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.

chrism2671
  • 2,579
  • 9
  • 34
  • 45
  • 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. – Michael Hampton Jul 07 '15 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 07 '15 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. – Michael Hampton Jul 07 '15 at 16:12
  • Is there an LXC or similar solution that would be more appropriate? – chrism2671 Jul 07 '15 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. – Michael Hampton Jul 07 '15 at 16:27
  • I'm creating development environments for developers, accessible over remote desktop, so that they can set up their IDE etc as they like. Currently the cost of giving each dev their own on-demand instance is prohibitive, especially as with interactive use, they will be mostly idle. The ideal situation is to share resources so they can make efficient use of hardware. – chrism2671 Jul 07 '15 at 17:00
  • Eh? Don't they have workstations? – Michael Hampton Jul 07 '15 at 17:05
  • Yes, the problem with the workstations is reliability and accessibility from home. I've already got this working with on-demand instances (we have built a dispatcher app that manages all the instances), but we have to power them down at night to make it cost effective, which is less than ideal. If I can squeeze some more efficiency from the set up then everything will be perfect! – chrism2671 Jul 07 '15 at 17:26

1 Answers1

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.

Daniel t.
  • 9,291
  • 1
  • 33
  • 36
  • 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 09 '15 at 06: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 '15 at 02:49