docker 安装 Tomcat
# 官方的使用
docker run -it --rm tomcat:9.0
# 我们之前的启动都是后台,停止了容器后,容器还是可以看到,docker run -it --rm tomcat:9.0 一般用来测试 用完删除
# 下载
docker pull tomcat
# 启动
docker run -d -p 3355:8080 --name tomcat01 tomcat
# 进入容器
[root@liulihui /]# docker exec -it e67061ce3e06 /bin/bash
# 发现问题:1、linux命令少了,2、没有webapps ,阿里云镜像的原因,默认是最小的镜像,所有不必要的都剔除掉了
# 保证最小可运行环境!
tomcat 测试完成
docker 安装 Nginx
# 1、搜索镜像 search ,建议大家docker 搜索,官方帮助文档
# 2、下载镜像 pull
# 3、运行测试
[root@liulihui /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat latest fb5657adc892 11 months ago 680MB
centos latest 5d0da3dc9764 14 months ago 231MB
# 下载nginx
[root@liulihui /]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a2abf6c4d29d: Already exists
a9edb18cadd1: Already exists
589b7251471a: Already exists
186b1aaa4aa6: Already exists
b4df32aa5a72: Pull complete
a0bcbecc962e: Pull complete
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
# 查看nginx 镜像
[root@liulihui /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 605c77e624dd 11 months ago 141MB
tomcat latest fb5657adc892 11 months ago 680MB
centos latest 5d0da3dc9764 14 months ago 231MB
# 运行nginx 镜像
# -d 后台运行
# --name 给容器命名
# -p 宿主机端口,容器内部端口
# 运行 nginx
[root@liulihui /]# docker run -d --name nginx01 -p 3344:80 nginx
0c1cdefd2867da131c17963f0e96ea9037e74ef54927d52ebf794b8b39820e7c
# 查看运行镜像
[root@liulihui /]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0c1cdefd2867 nginx "/docker-entrypoint.?? 19 seconds ago Up 17 seconds 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
01c5a340f05d tomcat "catalina.sh run" 14 hours ago Exited (143) 14 hours ago tomcat01
# 本地测试运行情况
[root@liulihui /]# 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@liulihui /]# docker exec -it nginx01 /bin/bash
root@0c1cdefd2867:/# ls
bin boot dev docker-entrypoint.d docker-entrypoint.sh etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@0c1cdefd2867:/# whereis nignx
nignx:
root@0c1cdefd2867:/# cd etc/nginx/
root@0c1cdefd2867:/etc/nginx# ls
conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params
端口暴露概念
docker 安装 es+kibana
# es 暴露的端口很多
# es 十分的耗内存
# es 的数据一般需要放置到安全目录!挂载
# --net somenetwork 网络配置
# 启动 elasticsearch
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2
# 启动了linux 服务器就非常卡, docker stats 查看cup状态
# 测试下一es是否成功了
[root@liulihui /]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
20610d5c3009 elasticsearch:7.6.2 "/usr/local/bin/dock?? 15 seconds ago Up 11 seconds 0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp elasticsearch
# 本地测试
[root@liulihui /]# curl localhost:9200
{
"name" : "20610d5c3009",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "BvOwNOvjT-ylSOOwJ4SKQA",
"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"
}
es 是十分耗内存 ,查看cpu的状态 docker stats
赶紧关掉es 增加内存限制;
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
查看 docker stats
测试
[root@liulihui /]# curl localhost:9200
{
"name" : "de39ee94dfaa",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "QONcZm8ESR2t9oDKfilCHA",
"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"
}