Skip to content

Instantly share code, notes, and snippets.

@zeitounator
Last active August 6, 2021 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeitounator/4ae161aacb03f988f3c086dab80ce1d3 to your computer and use it in GitHub Desktop.
Save zeitounator/4ae161aacb03f988f3c086dab80ce1d3 to your computer and use it in GitHub Desktop.
# Port 8080 is already taken on my machine so I use a free one => 9999
$ docker run -d --rm --name testnginx -p 9999:80 nginx
c48960b23446714447471f1f1948f2eb3954e0b820ae34b4559ad5ab17bfc3ca
# At this point the container is up and running
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1d6a688f6675 nginx "/docker-entrypoint.…" 13 seconds ago Up 12 seconds 0.0.0.0:9999->80/tcp, :::9999->80/tcp testnginx
# Now let's call the mapped port on localhost and get the default nginx page
$ curl http://localhost:9999
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
# Cleanup time. Stopping is enough since we used --rm
$ docker stop testnginx
testnginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment