Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker有一个打开的端口,但它';配置文件中没有描述什么?_Docker_Docker Compose_Dockerfile_Docker Machine - Fatal编程技术网

Docker有一个打开的端口,但它';配置文件中没有描述什么?

Docker有一个打开的端口,但它';配置文件中没有描述什么?,docker,docker-compose,dockerfile,docker-machine,Docker,Docker Compose,Dockerfile,Docker Machine,我有两个DockerFile:一个使用nginx,另一个使用php。带有php的容器公开了端口9000,但docker-compose.yml或Dockerfile中没有对其进行描述 是什么让docker打开端口9000 有人遇到过这个问题吗?任何帮助都将不胜感激。) 复制步骤 docker compose.yml version: "3.4" services: nginx: build: context: .

我有两个DockerFile:一个使用nginx,另一个使用php。带有php的容器公开了端口9000,但docker-compose.yml或Dockerfile中没有对其进行描述

是什么让docker打开端口9000

有人遇到过这个问题吗?任何帮助都将不胜感激。)

复制步骤

docker compose.yml

version: "3.4"

services:
    nginx:
        build:
            context: .
            dockerfile: ./Dockerfile-Nginx
        container_name: nginx
        image: nginx
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - ./web:/var/www/vhosts
            - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
            - ./config/nginx/common-nginx-host.conf:/etc/nginx/common-nginx-host.conf:ro
            - ./config/nginx/csp.conf:/etc/nginx/csp.conf:ro
            - ./config/nginx/expires-map.conf:/etc/nginx/expires-map.conf:ro
            - ./config/nginx/mime.types:/etc/nginx/mime.types:ro
            - ./config/nginx/sites-enabled:/etc/nginx/sites-enabled:ro
            - ./logs/nginx:/var/log/nginx
            - ./data/letsencrypt:/etc/letsencrypt
        environment:
            - TZ=Etc/UTC
        links:
            - php
        networks:
          - local
        restart: always
    php:
        build:
            context: .
            dockerfile: ./Dockerfile-PHP7.4
        container_name: php
        image: php
        volumes:
            - ./web:/var/www/vhosts
            - ./logs/php/7.4:/var/log/php
            - ./config/php/7.4/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
        environment:
            - TZ=Etc/UTC
        networks:
            - local
        restart: always
    networks:
        local:
           driver: bridge
Dockerfile Nginx

FROM ubuntu:latest as nginx

RUN \
        apt-get -yqq update && \
        apt-get -yqq install nginx && \
        apt-get install -y tzdata && \
        apt-get install -yqq --no-install-recommends apt-utils && \
        apt-get -yqq install software-properties-common && \
        apt-get -yqq install && \
        LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && apt-get update && \
        apt-get install -yqq php7.4 php7.4-cli php7.4-common php7.4-mysql && \
        apt-get -yqq install letsencrypt && \
        apt-get clean


WORKDIR /var/www/vhosts

CMD ["nginx", "-g", "daemon off;"]
Dockerfile-PHP7.4

FROM php:7.4-fpm as php-fpm-7.4

RUN \
        apt-get update  -yqq && \
        apt-get install -yqq \
                xvfb libfontconfig wkhtmltopdf \
                git sass \
                libpng-dev \
                libjpeg-dev \
                libzip-dev \
                libfreetype6-dev \
        libxrender1 \
        libfontconfig1 \
        libx11-dev \
        libxtst6 \
        zlib1g-dev \
        imagemagick \
        libmagickwand-dev \
        libmagickcore-dev \
        libmemcached-dev && \
        pecl install memcached && \
    yes '' | pecl install imagick && \
        docker-php-ext-install gd && \
    docker-php-ext-enable gd && \
    docker-php-ext-enable imagick && \
    docker-php-ext-enable memcached && \
        docker-php-ext-configure pdo_mysql --with-pdo-mysql && \
        docker-php-ext-install -j$(nproc) \
        pdo_mysql \
    zip

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

COPY config/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml


RUN ${TZ} > /etc/timezone

CMD ["php-fpm"]
nginx配置文件的一部分

location /index.php {

                # Rate limiting
                limit_req zone=defaultlimit burst=40 nodelay;
                limit_req_status 444;
                limit_req_log_level warn;

                fastcgi_split_path_info  ^(.+.php)(.*)$;

                set $fsn /index.php;
                if (-f $document_root$fastcgi_script_name){
                        set $fsn $fastcgi_script_name;
                }

                #include snippets/fastcgi-php.conf;
                fastcgi_pass php:9000;

                include fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;

                #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
                fastcgi_param  PATH_INFO        $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
        }

这是因为它暴露在父docker映像中(php:7.4-fpm)


您的PHP Dockerfile从PHP:7.4-fpm中声明

php:7.4-fpm
公开了端口9000