需要先pull下来
#启动nginx
-d 表示后台运行
-p 表示暴露端口,将80暴露为3344
[root@iZf8zhsqf64x47n1tpdy6oZ home]# docker run -d -p:3344:80 nginx
5dd62cea7681975d37d1a9867bc9776de0206519f624b461346ac83025656642
[root@iZf8zhsqf64x47n1tpdy6oZ home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5dd62cea7681 nginx "/docker-entrypoin..." 5 seconds ago Up 4 seconds 0.0.0.0:3344->80/tcp inspiring_bell
af3bc99f4a47 portainer/portainer "/portainer" 2 days ago Up 27 hours 8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp portainer
#本机自测
[root@iZf8zhsqf64x47n1tpdy6oZ home]# 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@iZf8zhsqf64x47n1tpdy6oZ home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5dd62cea7681 nginx "/docker-entrypoin..." 19 minutes ago Up 19 minutes 0.0.0.0:3344->80/tcp inspiring_bell
af3bc99f4a47 portainer/portainer "/portainer" 2 days ago Up 27 hours 8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp portainer
#进入容器内部
[root@iZf8zhsqf64x47n1tpdy6oZ home]# docker exec -it 5dd62cea7681 /bin/bash
root@5dd62cea7681:/# whereis nginx
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@5dd62cea7681:/# cd /etc/nginx
root@5dd62cea7681:/etc/nginx# ls
conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params
root@5dd62cea7681:/etc/nginx#
#当直接运行时不存在就会去下载
docker run -it --rm tomcat:9.0
--rm表示运行完成后就会自己删除,我们之前的都是不会自动删除的
遇到的问题:当我们运行了tomcat之后,是无法访问tomcat的首页的,这是因为镜像使得tomcat变成精简版本,只要能运行的版本就行,所以,如果想访问的话,就需要进行相关操作
#进入tomcat
[root@iZf8zhsqf64x47n1tpdy6oZ home]# docker exec -it 9f62708dfca5 /bin/bash
root@9f62708dfca5:/usr/local/tomcat# ls
BUILDING.txt LICENSE README.md RUNNING.txt conf logs temp webapps.dist
CONTRIBUTING.md NOTICE RELEASE-NOTES bin lib native-jni-lib webapps work
root@9f62708dfca5:/usr/local/tomcat# cd webapps
#发现webapps里面为空
root@9f62708dfca5:/usr/local/tomcat/webapps# ls
root@9f62708dfca5:/usr/local/tomcat/webapps# cd ..
#复制webapps.dist文件内容到webapps中去
root@9f62708dfca5:/usr/local/tomcat# cp -r webapps.dist/* webapps
root@9f62708dfca5:/usr/local/tomcat# cd webapps
root@9f62708dfca5:/usr/local/tomcat/webapps# ls
ROOT docs examples host-manager manager
root@9f62708dfca5:/usr/local/tomcat/webapps#
问题解决!!
elasticsearch是什么耗内存的,因此需要修改配置,限制内存
#限制最大内存为512m,最小内存为64m
[root@iZf8zhsqf64x47n1tpdy6oZ home]# docker run -d -p 9200:9200 -e 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.6.2
docker run -d -p 8088:9000 \
--restart=always -v /var/run/docker.sock:/var/run/docker.sock --privileged=true portainer/portainer