Running Nginx dengan docker

Ini adalah guide Running Nginx dengan Docker

Prerequisties :

berikut step running nginx dengan docker

  1. Pull images nginx terbaru. (kecepatan tergantung koneksi kalian)
$ docker pull nginx:latest

Jika telah selesai, lihat images yang sudah di download

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              c7460dfcab50        30 hours ago        126MB
hello-world         latest              fce289e99eb9        12 months ago       1.84kB
  1. Run container dengan image nginx yang sudah di pull. container akan dinamakan mycontainer dan running port 8080
$ docker run --name mycontainer -p 8080:80 nginx:latest
  1. buka terminal baru untuk melihat apakah container running
$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
b80639e011db        nginx:latest        "nginx -g 'daemon of…"   22 seconds ago      Up 21 seconds       0.0.0.0:8080->80/tcp   mycontainer
$ curl localhost:8080
<!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>

Selamat, Running Nginx dengan Docker telah berhasil!.

tambahan, apabila ingin running container di background, dapat menggunakan option ‘-d’ atau ‘–detach’ pada step nomor 2

$ docker run -d --name mycontainer -p 8080:80 nginx:latest
Written on January 10, 2020