DEV Community

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

Posted on

7

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.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay