「CentOS8.3」dockerでnginxを起動する方法

1.OSバージョン確認
# cat /etc/redhat-release
CentOS Linux release 8.3.2011

2.dockerバージョン確認
# docker –version
Docker version 20.10.5, build 55c4c88

3.runオプション説明
–name: 任意のイメージ名
-d: デタッチモード
-p: ポート番号指定

4.実行例
# docker run –name testnginx -d -p 8090:80 nginx

Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
45b42c59be33: Pull complete
8acc495f1d91: Pull complete
ec3bd7de90d7: Pull complete
19e2441aeeab: Pull complete
f5a38c5f8d4e: Pull complete
83500d851118: Pull complete
Digest: sha256:f3693fe50d5b1df1ecd315d54813a77afd56b0245a404055a946574deb6b34fc
Status: Downloaded newer image for nginx:latest
64ea54eb6dcba5aeceb99d34bd4a00702bb5d7c93cf0d031281c1362750a808b

5.curlコマンドでnginxのwelcome画面にアクセスする
# curl http://localhost:8090

結果

<!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>

 

CentOS

Posted by arkgame