Skip to main content

AWS Lightsail Instances

This guide outlines the steps to launch a Docker container on an AWS Lightsail instance, pulling the image from a private Amazon Elastic Container Registry (ECR) repository. This guide assumes a RHEL-based (e.g., Amazon Linux, Fedora, CentOS) Lightsail instance that uses dnf or yum.

Prerequisites

  • An active AWS account.
  • An AWS Lightsail instance (RHEL-based Linux distribution).
  • Your ECR repository URI and image tag.
  • AWS Access Key ID and Secret Access Key provided by Eclypses with ECR Read Permissions.

Video Guide


Step 1: Connect to Lightsail Instance and Configure AWS CLI

Connect to your Lightsail instance and configure the AWS CLI using the credentials provided by Eclypses.

  1. Connect to Lightsail Instance:

    • Go to your Lightsail console.
    • Click on your instance name, then click the Connect button to open an SSH session in your browser, or use your preferred SSH client.
  2. Install AWS CLI (if not already installed):

    sudo dnf install awscli -y
  3. Configure AWS CLI:

    aws configure

    You will be prompted to enter the following:

    • AWS Access Key ID: Paste the Access Key ID provided by Eclypses.
    • AWS Secret Access Key: Paste the Secret Access Key provided by Eclypses.
    • Default region name: Enter us-east-1 (or your ECR repository's region).
    • Default output format: You can leave this blank or enter json.

Step 2: Install Docker

Check if Docker is installed. If not, install and start the Docker service.

  1. Check Docker Installation:

    docker -v
  2. Install Docker (if not installed): If the previous command indicates Docker is not installed, run:

    sudo dnf update -y
    sudo dnf install docker -y
    sudo systemctl start docker
    sudo systemctl enable docker

Note: Depending on your OS and Package Manager, the commands may be different. The goal is to install Docker on your system.


Step 3: Authenticate Docker with ECR and Pull the Image

Authenticate Docker with ECR and pull your private image. If you encounter permission errors, add your user to the docker group.

  1. Log in to ECR: This command gets a temporary authorization token from ECR and pipes it to docker login.

    aws ecr get-login-password \
    --region us-east-1 \
    | docker login --username AWS \
    --password-stdin 321186633847.dkr.ecr.us-east-1.amazonaws.com

    Replace 321186633847.dkr.ecr.us-east-1.amazonaws.com with your ECR repository's URI. You should see Login Succeeded.

  2. Grant Docker Permissions to your User (if needed): If you encounter permission denied errors when trying to run Docker commands, your user needs to be added to the docker group.

    sudo usermod -aG docker $USER

    After running this, you must log out and log back in to your Lightsail instance for the group changes to take effect.

    exit

    Then reconnect via SSH.

  3. Pull the Docker Image:

    docker pull 321186633847.dkr.ecr.us-east-1.amazonaws.com/customer/on-prem/mte-relay-server:4.5.0

    Replace the repository URI and tag with your specific image details.


Step 4: Run the Docker Container

Run your Docker container using the pulled image, mapping port 80 on the host. Remember to properly quote environment variables containing special characters like JSON.

docker run \
-p 80:8080 \
-e AWS_REGION=us-west-2 \
-e 'DOMAIN_MAP={ "*": { "upstream": "https://eclypses.com", "cors_origins": [ "*" ], "client_id_secret": "bFG9pHKswzVKFkhSVrpMHDzKTrqUptc6" } }' \
--rm \
321186633847.dkr.ecr.us-east-1.amazonaws.com/customer/on-prem/mte-relay-server:4.5.0

Finally, check that your server is accessible by using a web browser to visit the following URL

http://__IP_ADDRESS__/api/mte-echo

Step 5: Next Steps

  1. Consult the On-Prem server configuration guide here.
  2. Consult the On-Prem server deployment guide here to learn about using Docker Swarm or Kubernetes to deploy your container.