Docker6:Docker部署Nginx

Docker6:Docker部署Nginx

Created
Nov 16, 2021 08:16 AM
Last Edited
Last updated December 2, 2021
Tags

1. 部署Nginx

# 1. 搜索镜像 search,建议去DockerHub上搜索 docker search nginx # 2. 拉取镜像 docker pull nginx # 3. 运行测试 将80端口映射到3344,-d后台运行,-p指定端口 docker run -d --name nginx01 -p 3344:80 nginx # 4. 进入容器,-it交互运行,进入容器 docker exec -it nginx01 /bin/bash # 5. 停止容器 docker stop 容器id
 

2. 查看部署

2.1 通过命令查看

curl localhost:3344
root@docker:/home/henggao/Desktop# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES root@docker:/home/henggao/Desktop# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 04661cdce581 6 days ago 141MB hello-world latest feb5d9fea6a5 7 weeks ago 13.3kB centos latest 5d0da3dc9764 2 months ago 231MB root@docker:/home/henggao/Desktop# docker run -d --name nginx01 -p 3344:80 nginx 343e5e05a37072c29b9f72be17b26a7066b5667053a4cbc3a49c4927e387b102 root@docker:/home/henggao/Desktop# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 343e5e05a370 nginx "/docker-entrypoint.…" 12 seconds ago Up 11 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01 root@docker:/home/henggao/Desktop# curl localhost:3344 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } 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> root@docker:/home/henggao/Desktop#
 

2.2 浏览器查看

notion image