DEV Community

Cover image for Deploy Nginx "Hello World" App using Docker
Marcos Popa
Marcos Popa

Posted on

Deploy Nginx "Hello World" App using Docker

Here is a step-by-step guide to deploy a Docker Nginx "Hello World" app:

  1. Install Docker on your machine. You can find the installation instructions for your operating system at the official Docker website.

  2. Create a new directory for your app and navigate to it in your terminal.

  3. Create a new file named "Dockerfile" in this directory and paste the following content:

FROM nginx:alpine
COPY index.html /usr/share/nginx/html/

Enter fullscreen mode Exit fullscreen mode
  1. Create an "index.html" file in the same directory with the following content:
<!DOCTYPE html>
<html>
  <head>
    <title>Hello World</title>
  </head>
  <body>
    <h1>Hello World</h1>
  </body>
</html>

Enter fullscreen mode Exit fullscreen mode
  1. Run the following command in your terminal to build the Docker image:

docker build -t hello-world-nginx .

  1. Run the following command to start a new container based on the image you just built:

docker run -p 8080:80 hello-world-nginx

  1. Visit http://localhost:8080 in your browser to see the "Hello World" message displayed by Nginx.

That's it! You have successfully deployed a Docker Nginx "Hello World" app.

Top comments (0)