nginx部署

搜索镜像
docker search nginx

  1. [root@iZbp1d0213clo5fn6z0fsfZ ~]# docker search nginx
  2. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  3. nginx Official build of Nginx. 14954 [OK]

下载镜像
docker pull nginx

  1. [root@iZbp1d0213clo5fn6z0fsfZ ~]# docker pull nginx

运行镜像
docker run

  1. [root@iZbp1d0213clo5fn6z0fsfZ ~]# docker run -d --name nginx01 -p:3344:80 nginx
  2. -d # 后台运行
  3. --name # 重命名
  4. -p #端口映射 宿主机端口:容器端口

测试
curl localhost:3344

  1. [root@iZbp1d0213clo5fn6z0fsfZ ~]# curl localhost:3344
  1. [root@iZbp1d0213clo5fn6z0fsfZ ~]# docker ps
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. 1af860000c35 nginx "/docker-entrypoint.…" 39 minutes ago Up 39 minutes 0.0.0.0:3344->80/tcp, :::3344->80/tcp nginx01
  4. ab46e08c6a9b jenkins/jenkins "/sbin/tini -- /usr/…" 4 weeks ago Up 4 weeks 50000/tcp, 0.0.0.0:80->8080/tcp, :::80->8080/tcp jenkins1
  5. bb2d540a590f mysql:8 "docker-entrypoint.s…" 5 weeks ago Up 5 weeks 33060/tcp, 0.0.0.0:3307->3306/tcp, :::3307->3306/tcp mysql8
  6. [root@iZbp1d0213clo5fn6z0fsfZ ~]# docker exec -it 1af860000c35 /bin/bash
  7. root@1af860000c35:/# whereis nginx
  8. nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
  9. root@1af860000c35:/# cd /etc/nginx
  10. root@1af860000c35:/etc/nginx# ls
  11. conf.d fastcgi_params mime.types modules nginx.conf scgi_params uwsgi_params
  12. root@1af860000c35:/etc/nginx#

思考
我们每次更改nginx配置,都需要进入到容器内部,十分麻烦,如果可以在容器外部提供一个映射路径,达到在容器修改文件,在内部可以自动修改。-v 数据卷
测试

  1. docker run -it --rm 镜像
  2. 一般用于测试,用完删除

tomcat部署

  1. docker search tomcat:9.0
  2. docker pull tomcat:9.0
  3. docker run -d --name tomcat01 -p:3344:8080 tomcat:9.0
  4. docker exec -it 容器id /bin/bash
  5. cp -r webapps.dist/* webapps

es+kibana部署