Docker学习笔记 (7)

image-20210203191513023

问题:我们以后要部署项目,如果每次都要进入容器是不是十分麻烦?要是可以在容器外部提供一个映射路径,比如webapps,我们在外部放置项目,就自动同步内部就好了!

3. 安装 elasticsearch + kibana # es 暴露的端口很多! # es 十分耗内存 # es 的数据一般需要放置到安全目录!挂载 # --net somenetwork ? 网络配置 # 启动elasticsearch [root@iz2zeak7sgj6i7hrb2g862z ~]# docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.2 # 测试一下es是否成功启动 ➜ ~ curl localhost:9200 { "name" : "d73ad2f22dd3", "cluster_name" : "docker-cluster", "cluster_uuid" : "atFKgANxS8CzgIyCB8PGxA", "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" } #测试成功就关掉elasticSearch,防止耗内存 [root@iz2zeak7sgj6i7hrb2g862z ~]# docker stop d834ce2bd306 d834ce2bd306 [root@iz2zeak7sgj6i7hrb2g862z ~]# docker stats # 查看docker容器使用内存情况

image-20210203192808256

#测试成功就关掉elasticSearch,可以添加内存的限制,修改配置文件 -e 环境配置修改 ➜ ~ docker rm -f d73ad2f22dd3 # stop命令也行 ➜ ~ docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xmx512m" elasticsearch:7.6.2

image-20210203192821029

➜ ~ curl localhost:9200 { "name" : "b72c9847ec48", "cluster_name" : "docker-cluster", "cluster_uuid" : "yNAK0EORSvq3Wtaqe2QqAg", "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. Portainer 可视化面板安装

portainer(先用这个)

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

Rancher(CI/CD再用)

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

# 安装命令 [root@iz2zeak7sgj6i7hrb2g862z ~]# docker run -d -p 8080: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 81753869c4fd438cec0e31659cbed0d112ad22bbcfcb9605483b126ee8ff306d

测试访问: 外网:8080 ::8080/

进入之后的面板

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsxyyx.html