Here is a step-by-step guide to deploy a Docker Nginx "Hello World" app:
Install Docker on your machine. You can find the installation instructions for your operating system at the official Docker website.
Create a new directory for your app and navigate to it in your terminal.
Create a new file named "Dockerfile" in this directory and paste the following content:
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/
- 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>
- Run the following command in your terminal to build the Docker image:
docker build -t hello-world-nginx .
- Run the following command to start a new container based on the image you just built:
docker run -p 8080:80 hello-world-nginx
- 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)