Docker Basics 1


Docker is a tool for containerization, enabling you to run applications in isolated environments. In this blog, we’ll cover the basics of Docker commands and demonstrate how to run a static website on your local host while binding it to a specific port.


docker pull prakhar1989/static-site

docker pull downloads container images from a registry to your local system.


docker run -p8888:80 -d prakhar1989/static-site

The docker run -p8888:80 -d prakhar1989/static-site command is used to run a Docker container with the following options:

  • -p8888:80: This option maps port 8888 on your local machine to port 80 within the container. It allows you to access the container’s web service on your local system via port 8888.
  • -d: This option runs the container in detached mode, meaning it runs in the background, and you get your terminal prompt back for further commands.
  • prakhar1989/static-site: This specifies the name of the Docker image you want to run, in this case, an image named “prakhar1989/static-site.”

So, this command starts a detached container based on the “prakhar1989/static-site” image, mapping your local machine’s port 8888 to the container’s port 80 to access a web service provided by the container.


docker ps

docker ps lists the currently running Docker containers on your system, providing information about their Container ID, image, status, ports, and other details.


When we navigate to our local host using the specified port, we can access the static website.


docker stop 5807484962ce halts the Docker container with the given Container ID.

docker stop 5807484962ce

After stopping the Docker container, the static website will no longer be accessible.