Currently Lightsail does not feature a Docker blueprint, but that's not really an issue. We can use the optional launch script to install Docker and make other necessary changes to the system. In the case of this tutorial you'll create an instance with a launch script that installs Docker and Docker Compose. It will also copy in the Docker Compose file that defines our application, and it will modify systemd so that on subsequent reboots our application automatically restarts.
-
From the Lightsail console click
Create Instance
. -
Choose whichever region you prefer.
-
Under
Select a blueprint
click onOS Only
and choose the Ubuntu image. -
Click on
+ Add launch script
. -
Enter the following code into the dialog box:
curl -o lightsail-compose.sh https://raw.githubusercontent.com/hashdog/lightsail-docker-compose/master/lightsail-compose.sh chmod +x ./lightsail-compose.sh ./lightsail-compose.sh
Note: To see contents of that script, please visit the github repository
-
Choose the appropriate instance size. In this case, there's no reason to do anything more than the $5 size.
-
Optionally rename the instance.
-
Click
Create
.Lightsail will launch a new instances, copy in our shell script, and execute it on first boot.
The shell script installs
docker
anddocker-compose
.
- Once the instance is up and running you can navigate to its IP address to see the running site.
-
To delete your Lightsail instance navigate to the Lightsail console, click the 3 dot menu in the upper right of the instance card, and click
Delete
.Confirm you wish to delete the instance.