From a2f0c389de21c125fa89cbdf87fab28434b5350d Mon Sep 17 00:00:00 2001 From: Art Date: Sun, 26 Sep 2021 10:26:04 +0300 Subject: [PATCH] 34.1. Create EC2 Docker instance (#34 deploy backend into docker ec2 instance, #32) --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 830e23a..78cf594 100644 --- a/README.md +++ b/README.md @@ -251,5 +251,29 @@ WantedBy=multi-user.target - `[Service]` - `Environment="SPRING_PROFILES_ACTIVE=aws-rds"` +#### Create EC2 instance for Docker + +- Create EC2 instance +- User Data: +```shell script +#!/bin/bash +yum update -y +amazon-linux-extras install -y docker +service docker start +usermod -a -G docker ec2-user +chkconfig docker on +mkdir -p /etc/systemd/system/docker.service.d +echo "[Service] + ExecStart= + ExecStart=/usr/bin/dockerd -H unix:// -H tcp://0.0.0.0:2375" > /etc/systemd/system/docker.service.d/options.conf +systemctl daemon-reload +systemctl restart docker +``` +- Security group: `docker-security-group` + - Allow 8080 (tomcat), 2375 (from my PC), 22 (SSH) +- Allocate Elastic IP: `docker-elastic-ip` +- Associate `docker-elastic-ip` with `docker-ec2` +- In Route 53 create record `dockerapp` with `docker-ec2` public IP + \ No newline at end of file