Search⌘ K
AI Features

Docker Kata 4: Running a Web Server in a Container

Explore how to run web servers in Docker containers with NGINX. Understand port publishing to run multiple server instances simultaneously, and practice accessing them from command line and browsers.

Containers are useful as components of complex information systems. Web servers are, of course, an important component of any web-based application. This kata will demonstrate how containers can be used to run a web server.

Step 1: Run a web server

The command to stop and remove all the containers is given below.

Shell
docker container stop $(docker container ls -q)
docker container rm $(docker container ls -aq)

The output will be something like this:

Commands

Parameter

Description

docker container stop $(docker container ls -q)

This stops and removes all the containers.

docker container rm $(docker container ls -aq)

These commands stop and remove all the containers.

The command to run a disconnected NGINX container is given below.

Shell
docker container run -d -p 80:80 --name webserver nginx

When ...