/lightsail-docker-compose

Lightsail + Docker + Docker Compose

Primary LanguageShell

lightsail-docker-compose

Docker containers with Docker Compose

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.

  1. From the Lightsail console click Create Instance.

  2. Choose whichever region you prefer.

  3. Under Select a blueprint click on OS Only and choose the Ubuntu image.

  4. Click on + Add launch script.

  5. 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

  6. Choose the appropriate instance size. In this case, there's no reason to do anything more than the $5 size.

  7. Optionally rename the instance.

  8. Click Create.

    Lightsail will launch a new instances, copy in our shell script, and execute it on first boot.

    The shell script installs docker and docker-compose.

  1. Once the instance is up and running you can navigate to its IP address to see the running site.

Cleanup

  1. 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.