# Installing Docker on AWS EC2 Ubuntu Instance

## Steps-:

To install Docker on an AWS EC2 Ubuntu instance, follow these steps:

1. Connect to your EC2 instance via SSH or the EC2 console.
    
2. Update the package list:
    

```plaintext
sudo apt update && sudo apt upgrade -y
```

1. Install prerequisite packages:
    

```plaintext
sudo apt install ca-certificates curl gnupg lsb-release
```

1. Add Docker's GPG key:
    

```plaintext
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
```

1. Add the Docker repository:
    

```plaintext
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```

1. Install Docker:
    

```plaintext
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

1. Check the Docker version:
    

```plaintext
docker -v
```

1. Add your user to the `docker` group:
    

```plaintext
sudo usermod -aG docker $USER
```

1. Log out and back in or run:
    

```plaintext
newgrp docker
```

1. Test Docker by running a container:
    

```plaintext
docker run hello-world
```

This installs Docker on your AWS EC2 Ubuntu instance and allows you to run Docker commands without `sudo`. Let me know if you have any other questions!
