Docker Fundamentals : Hands On - I
Setting Up Docker on AWS EC2 (Ubuntu)
Step 1: Update the Package List
sudo apt-get update
sudo apt-get upgrade
Step 2: Install Docker
sudo apt-get install docker.io
Step 3: Add User to Docker Group
sudo usermod -aG docker ubuntu && newgrp docker
Step 4: Verifying the Installation
docker --version
docker run hello-world
Common Docker Commands
1. docker pull
docker pull <image_name>
2. docker images
docker images
3. docker ps
docker ps
4. docker ps -a
docker ps -a
5. docker run
docker run <image_name>
6. docker run -d
docker run -d <image_name>
Hands-On: Setting Up a MySQL Container with Docker
Step 1: Pull the MySQL Docker Image
docker pull mysql:latest
Verify the Download
docker images
Recommended by LinkedIn
Step 2: Run the MySQL Container
docker run -d -e MYSQL_ROOT_PASSWORD=password mysql:latest
Explanation of Options:
Verify the Container Is Running
docker ps
Step 3: Access the Running Container
docker exec -it <container-id> bash
Explanation of Options:
Access MySQL CLI Inside the Container
mysql -u root -p
show databases;
Hands-On Guide: Setting Up NGINX with Docker
Step 1: Pull the NGINX Docker Image
docker pull nginx:latest
docker images
Step 2: Run the NGINX Container
docker run -d -p 80:80 --name my-nginx nginx:latest
Explanation:
Confirm that the container is running:
docker ps
Step 3: Access NGINX Using the EC2 Public IPv4 Address