Terminology (https://www.docker.com/blog/docker-for-web-developers/)
- Docker Hub: The world’s largest repository of container images, which helps developers and open source contributors find, use, and share their Docker-inspired container images.
- Docker Compose: A tool for defining and running multi-container applications.
- Docker Engine: An open source containerization technology for building and containerizing applications.
- Docker Desktop: Includes the Docker Engine and other open source components; proprietary components; and features such as an intuitive GUI, synchronized file shares, access to cloud resources, debugging features, native host integration, governance, and security features that support Enhanced Container Isolation (ECI), air-gapped containers, and administrative settings management.
- Docker Build Cloud: A Docker service that lets developers build their container images on a cloud infrastructure that ensures fast builds anywhere for all team members.
My successful experiment.
1.Download Docker desktop for Windows
https://www.docker.com/products/docker-desktop/
2.Install it
3.You may sign up (my username is my hotmail user name federated with my gmail)
(https://app.docker.com/accounts/debharit)
4.Run docker.desktop. It shows in the icon tray.
5.You may be asked to run command wsl --update in cmd to update Windows subsystem for Linux (WSL) then click restart to restart docker engine
6.Create a folder namely "getting-started-app" anywhere.
7.Within the created folder, create 2 files to get an HTTP server based on Nginx run on your Windows.
Dockerfile
# Use the official Nginx image from Docker Hub
FROM nginx:latest
# Copy the custom index.html file into the Nginx directory
COPY index.html /usr/share/nginx/html/index.html
index.html
<!DOCTYPE html>
<html>
<head>
<title>Hello, World!</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This page is served by Nginx in a Docker container.</p>
</body>
</html>
8.Open cmd window. Change directory into getting-started-app
9.Run the following command to build your container image, which extends nginx image from Docker hub by adding my index.html. The -t specifies the container's name. The . specifies the current directory as a build context.
docker build -t my-nginx-webserver .
10.Start my container by running my docker image.
docker run -d -p 8080:80 --name my-nginx-container my-nginx-webserver
The -d flag runs the container in "detached" mode (in the background).
The -p flag maps port 8080 on your local machine to port 80 inside the container, which is the default port Nginx listens on.
The --name my-nginx-container gives your container a memorable name.
Finally, you specify the name of the image you want to use (my-nginx-webserver).
11.Open http://localhost:8080 in your web browser to verify if it works.
12.Stop the container with this command:
docker stop my-nginx-container
13.Or you may start it again with this command:
docker start my-nginx-container
14.Remove your container after stopping it:
docker rm my-nginx-container
15.You may remove the image:
docker rmi my-nginx-webserver