Docker(5)- docker部署nginx
搜索nginx镜像
(建议去hub.docker.com上去查找)
# 下载镜像 docker pull nginx # 检查镜像是否下载成功 docker images [root@iZuf63tzd3n3bijtsfqsk5Z ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql latest bbf6571db497 10 days ago 516MB nginx latest f652ca386ed1 10 days ago 141MB hello-world latest feb5d9fea6a5 2 months ago 13.3kB centos latest 5d0da3dc9764 2 months ago 231MB # 运行容器 -d 后台运行 --name 自定义容器名 -p 主机端口:容器内端口 [root@iZuf63tzd3n3bijtsfqsk5Z ~]# docker run -d --name nginx01 -p 3344:80 nginx 4cc38119d9d67cecfe1a91c77835b796545d6e7ac0f72b7339aa55cf9bdf07d0
#检查是否成功,ping下端口
[root@iZuf63tzd3n3bijtsfqsk5Z ~]# 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>