docker笔记4-部署
docker笔记4-部署
一、部署nginx
docker search nginx #搜索nginx的最新版本
docker pull nginx #这里可以指定nginx版本,如果不指定,那么就拉取最新版本latest
docker run -d --name nginx01 -p 3344:80 nginx # -d: 运行后台进程,-p: 指定外界访问映射到容器的端口3344-> 80
docker exec -it
[root@ser878629168738 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>
docker ps # 查看正在运行的镜像
[root@ser878629168738 home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c890549787f nginx "/docker-entrypoint.…" 6 minutes ago Up 6 minutes 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
docker exec -it nginx01 /bin/bash # 切入到容器中
二、部署Tomcat
docker pull tomcat
[root@ser878629168738 home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 2 years ago 141MB
tomcat latest fb5657adc892 2 years ago 680MB
centos latest 5d0da3dc9764 2 years ago 231MB
docker run -d -p 3355:8080 --name tomcat01 tomcat #启动tomcat容器,命名为tomcat01
[root@ser878629168738 home]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
11699886abdc tomcat "catalina.sh run" 4 seconds ago Up 3 seconds 0.0.0.0:3355->8080/tcp, :::3355->8080/tcp tomcat01
docker exec -it 11699886abdc /bin/bash #切入到tomcat01中
三、部署ES+Kibana
3.1 部署ES
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2 # 这种方式下载的es占用cpu严重,会直接导致操作很卡
docker run -d --name elasticsearch02 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.6.2 # 这种方式就极大地减少了es占用cpu的比例
[root@ser878629168738 home]# docker stats 48ac2b94a32c
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
48ac2b94a32c elasticsearch02 0.00% 372.2MiB / 1.794GiB 20.26% 656B / 0B 96.9MB / 810kB 44
[root@ser878629168738 home]# curl localhost:9200
{
"name" : "48ac2b94a32c",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "uB1wJTFWSxmNnR7C1BGTtA",
"version" : {
"number" : "7.6.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
"build_date" : "2020-03-26T06:34:37.794943Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
3.2 部署kibana
docker search kibana
docker pull kibana #直接拉取最新kibana版本
docker run --name kibana01 -e ELASTICSEARCH_HOSTS=http://xxxxxx:9200 -p 5601:5601 -d kibana # 启动一个新的Docker容器,名为kibana01,运行Kibana服务,并将其配置为连接到运行在http://xxxxx:9200的Elasticsearch实例。容器内的5601端口被映射到宿主机的5601端口,以便用户可以通过浏览器访问Kibana的Web界面。容器将以分离模式在后台运行。
可以通过http://xxxxxx:5601
来访问kibana
原文地址:https://blog.csdn.net/qq_42569028/article/details/140621105
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!