Docker is a software platform that allows you to quickly build, test, and deploy applications. Docker packages software into standardized units called containers that have everything the software needs to run, including libraries, system tools, code, and runtimes. Using Docker, you can quickly deploy and scale your application into any environment and know with certainty that your code will run. Running Docker on AWS gives developers and administrators a low-cost and highly reliable way to build, ship, and run distributed applications of any size.
Docker partners with AWS to help developers quickly bring modern applications to the cloud. This partnership helps developers using Docker Compose and Docker Desktop to leverage the same local workflows they use today to seamlessly deploy applications on Amazon ECS and AWS Fargate.
Docker works by providing a standard method for running your code. Docker is an operating system for containers. In the same way that a virtual machine virtualizes (eliminating the need to directly manage) server hardware, containers virtualize the host’s operating system. Docker is installed on each host and provides simple commands that you can use to build, start, or stop containers.
AWS services like AWS Fargate, Amazon ECS, Amazon EKS, and AWS Batch make it easy to run Docker containers at scale.
In the lab, we execute basic Docker commands with AWS Cloud9
docker --version
docker pull [OPTIONS] NAME[: TAG|@DIGEST]
docker pull nginx\:latest
docker images [OPTIONS] [REPOSITORY[: TAG]]
docker images
docker run -d -p 8080:80 --name nginx nginx\:latest
-d: Run the container in the background
Name the container as nginx
-p 8080:80: Expose port 80 of container to port 8080 of machine host
nginx:latest: Container launched from image is nginx:latest
Reference command to run a container:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
docker ps
docker ps [OPTIONS]
curl http://localhost:8080
curl [options/URLs]
Also you can read more about CURL
docker logs nginx
docker logs [OPTIONS] CONTAINER
docker exec -it nginx /bin/bash
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
cd /usr/share/nginx/html
cat index.html
docker stop nginx
docker stop [OPTIONS] CONTAINER [CONTAINER...]
docker start nginx
docker ps -a
docker rm nginx
docker rm [OPTIONS] CONTAINER [CONTAINER...]
docker rmi nginx\:latest
docker rmi [OPTIONS] IMAGE [IMAGE...]