Amazon Lightsail is a new service on AWS which appears to be targeted at hosts like Digital Ocean and Linode. There’s a pretty neat “Launch Script” feature! Here’s a quick guide to automated Docker installs.

Login to AWS, jump to Lightsail, and select “Base OS” and the option for “Ubuntu 16.04”.
screenshot-2016-12-02-22-12-47

 

For this example, we’re going to use the Docker PHP Image. You’ll probably want to modify the last two lines of this script to pull your own Docker image. In the “Launch Script” box, enter this code:

You can login to DockerHub using:

sudo docker login --username=your_username --password=your_password123!

screenshot-2016-12-02-22-53-15

 

Select your SSH key. Choose your Instance plan. Give your instance a name.
screenshot-2016-12-02-22-53-33

 

Wait a few minutes… Even though the instance is “Running” the install script hasn’t completed. This takes between 2-5minutes, depending on how big the Docker image is.
screenshot-2016-12-02-22-58-10

 

View the page. In this example, a 403 error means the container is running but there’s nothing to serve. Success! You can SSH in and start editing.
screenshot-2016-12-02-22-58-34

That’s it and that’s all!

4 Comments

  1. bob

    Thank you, your example was very helpful! Do you know if there’s any way to view your launch script once the instance is launched? I couldn’t find it on the aws console, or anywhere on my instance file system.

Leave a Reply

Your email address will not be published. Required fields are marked *