# Docker Installation In EC2

Update the packages on your instance

**\[ec2-user ~\]$ sudo yum update -y**

Install Docker

**\[ec2-user ~\]$ sudo yum install docker -y**

Start the Docker Service

**\[ec2-user ~\]$ sudo service docker start**

Add the ec2-user to the docker group so you can execute Docker commands without using sudo.(to overcome the permission denied)

**\[ec2-user ~\]$ sudo usermod -a -G docker ec2-user**

**Create Docker Hub Account**

Login to Docker Hub

docker pull &lt;image-name&gt;

e.g. docker pull mysql

docker images:to see the docker images

docker run -d -e MYSQL\_ROOT\_PASSWORD=test\_123 mysql:latest--&gt;create a container

docker run -d -e MYSQL\_ROOT\_PASSWORD=test\_123 &lt;images\_name&gt;:latest--&gt;create a container

docker exec -it &lt;cid&gt; bash

bash4.4# mysql -u root -p

password:
