zoukankan      html  css  js  c++  java
  • Docker学习02-安装nginx,tomcat

    Docker安装nginx

    搜索nginx

    docker search nginx
    
    NAME                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    nginx                              Official build of Nginx.                        14825     [OK]       
    jwilder/nginx-proxy                Automated Nginx reverse proxy for docker con…   2024                 [OK]
    richarvey/nginx-php-fpm            Container running Nginx + PHP-FPM capable of…   813                  [OK]
    jc21/nginx-proxy-manager           Docker container for managing Nginx proxy ho…   186                  
    linuxserver/nginx                  An Nginx container, brought to you by LinuxS…   143                  
    tiangolo/nginx-rtmp                Docker image with Nginx using the nginx-rtmp…   123                  [OK]
    jlesage/nginx-proxy-manager        Docker container for Nginx Proxy Manager        106                  [OK]
    bitnami/nginx                      Bitnami nginx Docker Image                      95                   [OK]
    alfg/nginx-rtmp                    NGINX, nginx-rtmp-module and FFmpeg from sou…   94                   [OK]
    jasonrivers/nginx-rtmp             Docker images to host RTMP streams using NGI…   89                   [OK]
    nginxdemos/hello                   NGINX webserver that serves a simple page co…   68                   [OK]
    privatebin/nginx-fpm-alpine        PrivateBin running on an Nginx, php-fpm & Al…   53                   [OK]
    nginx/nginx-ingress                NGINX Ingress Controller for Kubernetes         51                   
    nginxinc/nginx-unprivileged        Unprivileged NGINX Dockerfiles                  33                   
    staticfloat/nginx-certbot          Opinionated setup for automatic TLS certs lo…   21                   [OK]
    schmunk42/nginx-redirect           A very simple container to redirect HTTP tra…   19                   [OK]
    nginx/nginx-prometheus-exporter    NGINX Prometheus Exporter                       17                   
    centos/nginx-112-centos7           Platform for running nginx 1.12 or building …   15                   
    centos/nginx-18-centos7            Platform for running nginx 1.8 or building n…   13                   
    bitwarden/nginx                    The Bitwarden nginx web server acting as a r…   12                   
    flashspys/nginx-static             Super Lightweight Nginx Image                   10                   [OK]
    bitnami/nginx-ingress-controller   Bitnami Docker Image for NGINX Ingress Contr…   8                    [OK]
    mailu/nginx                        Mailu nginx frontend                            8                    [OK]
    ansibleplaybookbundle/nginx-apb    An APB to deploy NGINX                          2                    [OK]
    wodby/nginx                        Generic nginx                                   1                    [OK]
    
    

    拉取nginx

    docker pull nginx # 拉取nginx
    

    查看是否下载成功

    docker images
    
    @K8S-APP-T02:/root#docker images
    REPOSITORY                                 TAG       IMAGE ID       CREATED         SIZE
    nacos/nacos-server                         latest    aa0ed1af6fc3   6 days ago      1.04GB
    mysql                                      latest    0627ec6901db   2 weeks ago     556MB
    nginx                                      latest    62d49f9bab67   3 weeks ago     133MB
    

    启动nginx

    docker run -d --name nginx01 -p 3344:80 nginx 端口映射,容器是80,宿主机是3344
    # -d 后台运行
    # --name 命名容器
    # -p 设置端口号
    
    CONTAINER ID   IMAGE                COMMAND                  CREATED          STATUS         PORTS      NAMES
    96139c808366   nginx                "/docker-entrypoint.…"   12 seconds ago   Up 9 seconds   0.0.0.0:3344->80/tcp, :::3344->80/tcp                  nginx01
    
    
    # 测试
    curl localhost:3344
    
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
             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>
    
    

    进入容器内查看nginx配置

    root@K8S-APP-T02:/root#docker exec -it nginx01 /bin/bash
    root@96139c808366:/# ls
    bin   dev		   docker-entrypoint.sh  home  lib64  mnt  proc  run   srv  tmp  var
    boot  docker-entrypoint.d  etc			 lib   media  opt  root  sbin  sys  usr
    root@96139c808366:/# where is nginx
    bash: where: command not found
    root@96139c808366:/# whereis nginx
    nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx
    

    docker run -it --rm tomcat:9.0 # 用于测试,用完就删除

    docker pull tomcat
    docker run -d -p 3355:8080 --name tomcat01 tomcat

    tomcat 安装

    docker run -it --rm tomcat:9.0 # 用于测试,用完就删除
    
    
    docker pull tomcat
    docker run -d -p 3355:8080 --name tomcat01 tomcat
    
    # 进入容器
    docker exce -it tomcat01 /bin/bash
    
    问题:1,linux命令少了。 2,没有了webapps,阿里云镜像的原因,
    
    解决方法:将webapps.dist 下的内容拷贝到webapps
    
    不论你在什么时候开始,重要的是开始之后就不要停止。 不论你在什么时候结束,重要的是结束之后就不要悔恨。
  • 相关阅读:
    Samba 4.0 RC3 发布
    SymmetricDS 3.1.7 发布,数据同步和复制
    Express.js 3.0 发布,Node.js 的高性能封装
    GIFLIB 5.0.1 发布,C语言的GIF处理库
    jQuery UI 1.9.1 发布
    SVN Access Manager 0.5.5.14 发布 SVN 管理工具
    DynamicReports 3.0.3 发布 Java 报表工具
    HttpComponents HttpClient 4.2.2 GA 发布
    AppCan 2.0 正式发布,推移动应用云服务
    Ruby 2.0 的新功能已经冻结
  • 原文地址:https://www.cnblogs.com/yunhgu/p/14743578.html
Copyright © 2011-2022 走看看