AWS Journey: Setting Up Development Tools on EC2
Following our EC2 instance setup, let's dive into preparing our development environment. First, as mentioned in our previous post, we'll need to upgrade our instance type from t2.micro to t2.small for better performance when running Docker containers.
Why Docker Compose and GitLab CI? I've been working with GitLab CI/CD for years, and I appreciate how it provides an all-in-one solution for version control, CI/CD pipelines, and runner management. Since I'm already using GitLab for repositories, it made sense to stick with its CI/CD tools for a seamless workflow.
For container management, I chose Docker Compose because it simplifies deploying monolithic applications by managing services and dependencies in a single file. While Kubernetes is powerful, it can be overkill for simpler applications. Docker Compose offers the perfect balance - allowing me to define everything in a structured way without needing complex orchestration tools. This setup has served me well across numerous projects where simplicity and maintainability are key priorities.
📝 Step-by-Step Guide
1. ➕ Instance Type Upgrade
Before we begin installing Docker, let's upgrade our instance type.
- This will affect your Free Tier eligibility
- Stop your instance first
- Change instance type to t2.small
- Start your instance again
- Verify the new instance type

2. 🐳 Docker Installation
Now that we have sufficient resources, let's set up Docker on our EC2 instance.
Update package index
sudo yum update -y
Install Docker
sudo yum install docker -y
Start Docker service
sudo systemctl start docker
Enable Docker service
sudo systemctl enable docker
Allow EC2 User to Run Docker Without Sudo (Optional)
sudo usermod -aG docker ec2-user
Verify Docker installation
docker --version

Test Docker functionality:
docker run hello-world

3. 🔧 Docker Compose Installation
Now that we have Docker installed, let's set up Docker Compose.
Download Docker Compose binary
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Make the Docker Compose binary executable
sudo chmod +x /usr/local/bin/docker-compose
Verify Docker Compose installation
docker-compose --version

4. 🔑 Setup GitLab CI Runner
Before we can run our CI/CD pipelines, we need to setup the GitLab CI Runner.
Navigate to your GitLab project's CI/CD settings:
- Go to Settings > CI/CD > Runners > New Project Runner
- Create a new runner
- tag the runner: You can use tags to control which jobs a runner can execute. We use "docker" tag because we want clean environments per job and proper isolation between jobs. This ensures each pipeline run starts with a fresh environment, preventing any conflicts from previous builds.
- add description: Add a description to the runner to help you identify it, it is optional so we can update it later.
- lock the runner: Lock the runner to the project. This means the runner will only run jobs for this project.
- maximum timeout: Set the maximum timeout for the runner. This is the maximum amount of time the runner can run for.
- Register the runner
- platform: Choose the platform you want to run the runner on. We choose "linux" because we are on an EC2 instance.
- copy the registration command from GitLab UI since we will use it in the next step:
gitlab-runner register --url https://gitlab.com --token YOUR_RUNNER_TOKEN
- Gitlab runner is successfully registered
GitLab Runner registration
5. 🔄 GitLab Runner Installation
After we have the runner & variables setup, we can install the GitLab Runner.
Add GitLab Runner Repository
curl -fsSL https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
Install GitLab Runner
sudo yum install -y gitlab-runner
Verify GitLab Runner installation
gitlab-runner --version
Register GitLab Runner
gitlab-runner register --url https://gitlab.com --token YOUR_TOKEN
- During the interactive registration, you'll be prompted to:
- Enter a description (e.g., "gitlab-runner-demo")
- Add tags (e.g., "docker")
- Choose executor (select "docker")
- Choose default Docker image (use the same version as the one that we installed in the previous step, eg: 25.0.5)
Start GitLab Runner service
sudo systemctl start gitlab-runner
Enable GitLab Runner service
sudo systemctl enable --now gitlab-runner
Check GitLab Runner status
sudo gitlab-runner status
Add GitLab Runner to Docker Group for running Docker commands without sudo
sudo usermod -aG docker gitlab-runner

⚠️ Common Pitfalls
- Running Docker commands without proper permissions
- Forgetting to start services after reboot
- Forgetting to save runner registration tokens
🌟 Learning Journey Highlights
✅ Docker Installation
- Docker version verification
- Docker hello-world test
✅ Docker Compose Installation
- Docker Compose version verification
✅ GitLab Runner Installation
- GitLab Runner version verification
- GitLab Runner registration
📈 Next Steps: CI/CD Pipeline
Now that we have our development environment set up with Docker, Docker Compose, and GitLab Runner, our next steps will focus on:
- Implementing CI/CD Pipeline
- Container Registry Setup (ECR)