Docker Set-up Guide
Note: because this configuration provides no monitoring, automatic restarts, failover, etc, this configuration is intended ONLY for development, test, and CI environments. Do not use this configuration for production - otherwise outages and data loss may occur.
This guide provides step-by-step instructions on deploying the UserClouds Docker container on an Amazon EC2 instance. This setup is useful for environments where you need to manage the Docker container lifecycle manually.
Prerequisites
- AWS Account
- AWS CLI configured
- Docker installed locally
Steps
- Launch an EC2 Instance
- Log in to the AWS Management Console.
- Launch an Instance:
- Navigate to EC2 Dashboard and click "Launch Instance".
- Choose an Amazon Machine Image (AMI). For this guide, we will use the Amazon Linux 2 AMI.
- Select an instance type. A t2.micro instance is sufficient for testing, but choose according to your needs.
- Configure other instance details as required.
- Configure security groups:
- Allow SSH (port 22) from your IP address.
- Allow HTTP (port 80) and HTTPS (port 443)
- Review and Launch:
- Review your instance settings and click "Launch".
- Select an existing key pair or create a new one to access your instance.
- Click "Launch Instances".
- Connect to Your Instance:
- Once the instance is running, click "Connect" and follow the instructions to SSH into your instance.
- Install Docker on the EC2 Instance
- Update the Installed Packages:
sudo yum update -y
- Install Docker:
sudo amazon-linux-extras install docker -y
- Start the Docker Service:
sudo service docker start
- Add the ec2-user to the Docker Group:
sudo usermod -a -G docker ec2-user
- Log Out and Log Back In (to ensure your user permissions are updated)
- Update the Installed Packages:
- Pull the UserClouds Docker Image
- Reach out to your UserClouds point of contact to obtain the Docker image and any necessary credentials for accessing the Docker registry where the image is hosted.
- Run the UserClouds Docker Container
- Run the Docker Container:
docker run -d --name userclouds-container -p 80:80 name-goes-here
- Replace
name-goes-here
with the name of the UserClouds Docker image. - Adjust the port mapping (
-p 80:80
) as needed.
- Replace
- Run the Docker Container:
- Verify the Deployment
- Check Running Containers:
docker ps
- Access Your Application: Open a web browser and navigate to the public IP address of your EC2 instance. You should see the UserClouds application running.
- Check Running Containers:
- Manual Lifecycle Management
- Since the Docker container will not automatically restart if the EC2 instance is terminated, you need to manage the lifecycle manually. Here are some commands to help:
- Stop the Docker Container:
docker stop userclouds-container
- Restart the Docker Container:
docker start userclouds-container
- Remove the Docker Container:
docker rm userclouds-container
- Remove the Docker Image:
docker rmi name-goes-here
- Stop the Docker Container:
- Since the Docker container will not automatically restart if the EC2 instance is terminated, you need to manage the lifecycle manually. Here are some commands to help:
By following these steps, you can successfully deploy and manage the UserClouds Docker container on an EC2 instance. This setup provides flexibility and control over the container lifecycle, although it requires manual intervention for tasks such as restarting the container if the instance is terminated.
Updated 4 months ago