# Run Syncloop on docker

## Overview

The Syncloop API platform can be easily run on a Docker container using the Docker CLI. This documentation provides instructions for running Syncloop on Docker, deploying it with Docker Compose, and running it on AWS ECS. Follow the steps below to get started.

## Prerequisites

Before running Syncloop on Docker, make sure you meet the following requirements:

1. **Install Docker CLI:** Ensure that you have Docker CLI installed on your machine. Visit the following link for instructions on how to set up Docker: [**Docker Installation Guide**](https://docs.docker.com/get-docker/).
    
2. **Pull Docker Image:** The Syncloop Docker image must be pulled from the Docker centralized repository. Make sure you have an outbound network allowance to access the Docker repository. Run the following command to pull the Syncloop image:
    
    ```bash
    docker pull nature9/syncloop-community
    ```
    

## Docker Images

Syncloop is available in two versions: `nature9/syncloop` and `nature9/syncloop-community`.

## Running Syncloop on Docker CLI

To run Syncloop on Docker using the CLI, execute the following command:

```bash
docker run -d -p 80:80 nature9/syncloop
```

For the community version, use the image `nature9/syncloop-community`.

## Running Syncloop with Docker Compose

You can deploy and manage multi-container applications using Docker Compose. Follow the steps below:

1. Create a file called `docker-compose.yaml` and add the following content:
    
    ```bash
    version: '2.1'
    services:
      syncloop:
        image: nature9/syncloop
        environment:
          - LOGGING_FILE=/eka/logs/server.log
        ports:
          - "80:80"
    ```
    
    Download the [docker-compose.yaml](https://www.syncloop.com/docker-compose.yml)
    

## Environmental Variables:

* `LOGGING_FILE`: Full path of the `server.log` file for logging.
    

To run Syncloop with Docker Compose, use the following command:

```bash
docker compose up
```

If the command executes successfully, it means Syncloop is now running on Docker. Open the following URL in your browser to access Syncloop: [**http://localhost:80**](http://localhost:80).

## Running Syncloop on AWS ECS

Developers can also deploy the Syncloop Docker container to the AWS ECS service using the local command tool. To do this [read more](https://docs.docker.com/cloud/ecs-integration/) in detail about how docker offers integration with AWS ECS.

Follow these steps:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1688389463444/d12617a2-96a6-4fb9-a6a6-f3e15eae3015.png align="center")

1. Create an IAM user with the following permissions
    

```bash

ec2:AuthorizeSecurityGroupIngress
application-autoscaling:*
elasticfilesystem:*
route53:GetHostedZone
logs:*
route53:GetHealthCheck
iam:CreateRole
iam:AttachRolePolicy
iam:PutRolePolicy
route53:ListHostedZonesByName
ecs:DeregisterTaskDefinition
servicediscovery:*
ecs:UpdateService
iam:GetRole
iam:PassRole
ecs:CreateService
iam:DetachRolePolicy
ec2:CreateSecurityGroup
ecs:ListTasks
iam:DeleteRolePolicy
ecs:RegisterTaskDefinition
ecs:DescribeServices
route53:DeleteHostedZone
logs:FilterLogEvents
ec2:DescribeRouteTables
ecs:DescribeTasks
route53:CreateHostedZone
logs:DescribeLogGroups
logs:DeleteLogGroup
ec2:CreateTags
ecs:CreateCluster
ecs:DeleteService
ecs:DeleteCluster
cloudformation:*
iam:DeleteRole
elasticloadbalancing:*
logs:CreateLogGroup
ec2:DescribeSecurityGroups
ecs:DescribeClusters
ec2:RevokeSecurityGroupIngress
ecs:ListAccountSettings
ec2:DescribeVpcs
ec2:DeleteSecurityGroup
ec2:DescribeSubnets
```

1. Create an [AWS ECS](https://docs.docker.com/cloud/ecs-integration/#create-aws-context) context using the following command:
    

```bash
docker context create ecs Syncloop-platform
```

1. Select the created context.
    
2. Create a file called `docker-compose.yaml` and add the following content:
    
    ```bash
    version: '2.1'
    services:
      syncloop:
        image: nature9/syncloop
        environment:
          - LOGGING_FILE=/logs/server.log
        ports:
          - "80:80"
        deploy:
          resources:
            limits:
              cpus: '0.5'
              memory: 1024M
          x-aws-autoscaling:
            min: 1
            max: 10 #required
            cpu: 75
        volumes:
          - eka_vol:/eka
    volumes:
      eka_vol:
    #    external: true
    #    name: fs-0d1781ddc5d739570
    x-aws-cloudformation:
      Resources:
        SyncloopTCP80TargetGroup:
          Properties:
            HealthCheckPath: /tenant/default/files/gui/middleware/pub/server/ui/welcome/onboarding/login.html
            Matcher:
              HttpCode: 200-499
        SyncloopTCP80Listener:
          Properties:
            Certificates:
              - CertificateArn: "arn:aws:acm:ap-south-1:776625503031:certificate/7a2b32cd-e894-4afd-b212-26f91ad31ce9"
            Protocol: HTTPS
            Port: 443
        Default80Ingress:
          Properties:
            FromPort: 443
            ToPort: 443
    ```
    
    Download the [`docker-compose.yaml`](https://www.syncloop.com/docker-compose-in.yml)
    
    1. Deploy Docker Compose on the ECS cluster using the following command:
        
        ```bash
        docker compose up
        ```
        
    
    Once the above command completes successfully, go to the [**AWS EC2 load balance**](https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fec2%2Fhome%3Fstate%3DhashArgs%2523LoadBalancers%253Asort%253DloadBalancerName%26isauthcode%3Dtrue&client_id=arn%3Aaws%3Aiam%3A%3A015428540659%3Auser%2Fec2&forceMobileApp=0&code_challenge=YARYvk7vqcjI0GLvbRhBTpC5vuRR3tBH4Ox8Z16k0i4&code_challenge_method=SHA-256) and select the **newly created AWS ELB**. Open the DNS name of the load balancer in your browser to access Syncloop.
    
    Syncloop supports both **HTTP and HTTPS**.
    
    Refer to the [Docker ECS documentation](https://docs.docker.com/cloud/ecs-integration/#setting-ssl-termination-by-load-balancer) to learn how to use your SSL certificate.
