部署nginx:
1. 搜索镜像 docker search nginx
2.拉取镜像 docker pull nginx 拉取最新nginx
3. 运行,修改默认端口为3344,名字改为nginx02(注:需要开启3344端口)
[root@wangstudy home]# docker run -d --name nginx02 -p 3344:80 nginx
7e6f7e37725d5ab44b633fc47f08f408fa1c2ee5ab23d238eab6999983a5ab49
[root@wangstudy home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7e6f7e37725d nginx "nginx -g 'daemon of…" 6 seconds ago Up 6 seconds 0.0.0.0:3344->80/tcp nginx02
daa744f190de nginx "nginx -g 'daemon of…" 8 minutes ago Up 8 minutes 80/tcp nginx01
[root@wangstudy home]# curl localhost:3344
<!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>
显示本机可以访问,同时公网也可访问
进入nginx02容器,查看内容
安装tomcat
官网命令:docker run -it --rm tomcat:9.0 --rm用完即删,用完即删
[root@wangstudy /]# docker run -it --rm tomcat:9.0
Unable to find image 'tomcat: