Install Docker and Git

Installing Docker

To allow the EC2 instance to package the source code and for the EC2 instance in the development environment to deploy that package as a server, we need to install Docker on both EC2 instances.

First, we need to SSH into the EC2 instance in the development environment and install Docker using the following command:

sudo yum install -y docker

3-setup-project

After the installation, we will start the Docker service on Linux:

sudo service docker start

Add the current Linux user to the Docker group so that the user can interact with Docker, and check if the current user can use Docker:

# Create group if it doesn't exist
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
docker ps

3-setup-project

Next, SSH into the EC2 instance in the production environment and install Docker following the same steps as above.

3-setup-project 3-setup-project

Installing Git

To clone the project we just forked onto the EC2 instance in the development environment, we need to install Git on that EC2 instance.

sudo yum install -y git-all

3-setup-project

Go to the project repository on GitHub and copy the URL to clone the source code.

3-setup-project

git clone https://github.com/{your-user-name}/imga

3-setup-project

And that’s it! We now have:

  • Docker and Git installed on the EC2 instance in the development environment (for source code management, packaging the source code, and pushing Docker images to ECR).
  • Docker installed on the EC2 instance in the production environment (for pulling Docker images from ECR and deploying the server).