部署Nginx:
#1. 搜索镜像 search
=> docker search nginx
#2. 拉取下载镜像 pull
=> docker pull nginx
#3. 查看是否下载成功镜像
=> docker images
#3. 运行测试
# -d 后台运行
# --name 给容器命名
# -p 宿主机端口:容器内部端口 相当于一个映射!!
=> docker run -d --name nginx01 -p 3344:80 nginx
aa664b0c8ed98f532453ce1c599be823bcc1f3c9209e5078615af416ccb454c2
#4. 查看正在启动的镜像
=> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
75943663c116 nginx "nginx -g 'daemon of…" 41 seconds ago Up 40 seconds 0.0.0.0:82->80/tcp nginx00
#5. 进入容器
=> docker exec -it nginx01 /bin/bash #进入
root@aa664b0c8ed9:/# whereis nginx #找到nginx位置
nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
root@aa664b0c8ed9:/# cd /etc/nginx/
root@aa664b0c8ed9:/etc/nginx# ls
conf.d fastcgi_params koi-utf koi-win mime.types modules nginx.conf scgi_params uwsgi_params win-utf
#6. 退出容器
=> exit
exit
#7. 停止容器
=> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aa664b0c8ed9 nginx "nginx -g 'daemon of…" 10 minutes ago Up 10 minutes 0.0.0.0:3344->80/tcp nginx01
[root@iz2zeak7sgj6i7hrb2g862z ~]# docker stop aa664b0c8ed9
注:每次改动nginx配置文件,都需要进入容器内部?十分麻烦,可以在容器外部提供一个映射路径,达到在容器外部修改文件名,容器内部就可以自动修改:
-v 数据卷 技术!vm集群中用ansible
部署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容器使用内存情况
docker status
查看cpu状态
#测试成功就关掉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