Docker部署nginx,tomcat,es,可视化

nginx

[root@iz2zeaet7s13lfkc8r3e2kz /]# docker pull nginx		#下载
Using default tag: latest
latest: Pulling from library/nginx
afb6ec6fdc1c: Pull complete 
b90c53a0b692: Pull complete 
11fa52a0fdc0: Pull complete 
Digest: sha256:30dfa439718a17baafefadf16c5e7c9d0a1cde97b4fd84f63b69e13513be7097
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@iz2zeaet7s13lfkc8r3e2kz /]# docker images		
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              9beeba249f3e        7 days ago          127MB
centos              latest              470671670cac        4 months ago        237MB
	# 后台启动nginx,名字为nginx01 映射到本机ip:9000
[root@iz2zeaet7s13lfkc8r3e2kz /]# docker run -d --name nginx01 -p 9000:80 nginx
d7da72bce53a84882b13595a2ce35d7f34c0dc217d3d3f396210c3a3d30bb4a4
[root@iz2zeaet7s13lfkc8r3e2kz /]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
d7da72bce53a        nginx               "nginx -g 'daemon of…"   9 seconds ago       Up 7 seconds        0.0.0.0:9000->80/tcp   nginx01
	# 查看
[root@iz2zeaet7s13lfkc8r3e2kz /]# curl localhost:9000



Welcome to nginx!



Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

#进入容器 [root@iz2zeaet7s13lfkc8r3e2kz /]# docker exec -it nginx01 /bin/bash root@d7da72bce53a:/# whereis nginx nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx root@d7da72bce53a:/# cd /etc/nginx root@d7da72bce53a:/etc/nginx# ls conf.d koi-utf mime.types nginx.conf uwsgi_params fastcgi_params koi-win modules scgi_params win-utf root@d7da72bce53a:/etc/nginx#

端口暴露的概念

Docker部署nginx,tomcat,es,可视化_第1张图片

tomcat

#官方的使用
docker run -it --rm tomcat:9.0

#我们之前的启动都是后台,停止了容器之后,容器还是可以查到	
# docker run -it --rm tomcat:9.0 官方这种方式一般用来测试,用完及删

#下载在启动
docker pull tomcat:9.0
# 测试
[root@iz2zeaet7s13lfkc8r3e2kz /]# docker pull tomcat:9.0
9.0: Pulling from library/tomcat
Digest: sha256:ce753be7b61d86f877fe5065eb20c23491f783f283f25f6914ba769fee57886b
Status: Image is up to date for tomcat:9.0
docker.io/library/tomcat:9.0
[root@iz2zeaet7s13lfkc8r3e2kz /]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              9.0                 1b6b1fe7261e        6 days ago          647MB
nginx               latest              9beeba249f3e        7 days ago          127MB
centos              latest              470671670cac        4 months ago        237MB

#启动
[root@iz2zeaet7s13lfkc8r3e2kz /]# docker run -d  -p 9000:8080 --name tomcat01 tomcat

#进入容器
[root@iz2zeaet7s13lfkc8r3e2kz /]# docker exec -it tomcat01 /bin/bash

#发现问题:1.linux命令少了,2.没有webapps,阿里云镜像的原因。默认是最小的镜像,所有不重要的都剔除掉。
# 保证最小可运行的环境!
#所有的文件都在webapps.dist下,复制到webapps下就可以访问tomcat
cp webapps.dist/* webapps

部署es

# es 暴露的端口很多!
# es 十分的耗内存
# es 的数据一般需要放置到安全目录!挂载
# --net somenetwork ? 网络配置

#启动
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e"discovery.type=single-node" elasticsearch:7.6.2

#启动了 linux就卡住了 docker stats 查看cpu的状态  慎重启动!!!

#es 是十分耗内存 1.xg  服务器是1核2g!就卡的要死要死的!!!

# 增加内存限制,修改配置文件 -e 环境配置修改
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@iz2zeaet7s13lfkc8r3e2kz /]# curl localhost:9200
{
  "name" : "ccada763b6c0",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "gVJt2oA6T1CpScqqRXhaMw",
  "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"
}

可视化

poryainer

docker run -d -p 8088:9000 \ --restart=always -v /var/run/docker.sock:/var/run/docker.sock --privileged=true portainer/portainer

什么是portainer?

docker图形化界面管理工具!提供一个后台面板供我们操作!

docker run -d -p 8088:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --privileged=true portainer/portainer

[root@iz2zeaet7s13lfkc8r3e2kz /]# docker run -d -p 8088:9000 --restart=always -v /var/run/docker.sock:/var/run/docker.sock --privileged=true portainer/portainer
Unable to find image 'portainer/portainer:latest' locally
latest: Pulling from portainer/portainer
d1e017099d17: Pull complete 
a7dca5b5a9e8: Pull complete 
Digest: sha256:4ae7f14330b56ffc8728e63d355bc4bc7381417fa45ba0597e5dd32682901080
Status: Downloaded newer image for portainer/portainer:latest
78d8db0506212d51fc673896e6db289c03bb5e1f287c2bab9d5d230faedab7d2
[root@iz2zeaet7s13lfkc8r3e2kz /]# docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
tomcat                latest              1b6b1fe7261e        6 days ago          647MB
nginx                 latest              9beeba249f3e        7 days ago          127MB
elasticsearch         7.6.2               f29a1ee41030        8 weeks ago         791MB
portainer/portainer   latest              2869fc110bf7        2 months ago        78.6MB
centos                latest              470671670cac        4 months ago        237MB

访问测试

Docker部署nginx,tomcat,es,可视化_第2张图片

你可能感兴趣的:(Docker部署nginx,tomcat,es,可视化)