Docker is a platform that packages up everything an application needs to run — code, runtime, libraries, tools, settings — and runs it as a container. Since everything the app needs is already inside the container, it cuts down on errors caused by mismatched environments across the developer's computer, the testing server, and the production server.
For example, errors from a mismatched Node version in a Node.js app, a PHP extension not being present, or bugs from a mismatched database setup — Docker gives you much more control over all of these.
# Run a pre-built Nginx web server container
# -d means run in the background
# -p 8080:80 maps your computer's port 8080 to the container's port 80
docker run -d -p 8080:80 nginxThis command runs a web server container using the official nginx image from Docker Hub. -p 8080:80 means opening http://localhost:8080 in your browser will show you the Nginx server running inside the container.
Opening http://localhost:8080 in your browser should show the "Welcome to nginx!" page.Info
8080 is the host port — the port on your own computer. 80 is Nginx's default web port inside the container. To change the port mapping, you could write, for example, -p 3000:80.