簡體   English   中英

錯誤:撰寫文件“./docker-compose.yml”無效,因為:services.mysql.ports 無效

[英]ERROR: The Compose file './docker-compose.yml' is invalid because: services.mysql.ports is invalid

錯誤:Compose 文件 './docker-compose.yml' 無效,因為:services.mysql.ports 無效:端口“3307”:3306 無效,應為 [[remote_ip:]remote_port[-remote_port]:]端口[/協議]

Using docker with Laravel sail on Laravel v8.7 trying to create a external port in Digital ocean droplet Ubuntu 20.04 Want to use multiple projects in one droplet in order to do that using separate containers but facing this issue. docekr-compsoer.yml

version: '3'
services:
    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.1
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.1/app
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
            XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
            XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
    mysql:
        image: 'mysql/mysql-server:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ROOT_HOST: "%"
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 1
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail
        healthcheck:
            test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
            retries: 3
            timeout: 5s
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local

**.env **

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:4KqkfLTvVorxQCcZMHxmxxUcmeg3JKNoMNfDbyVWSd8=
APP_DEBUG=true
APP_URL=http://localhost

APP_PORT="8080"
FORWARD_DB_PORT="3307"

//rest of the configs

docker-compose中端口映射規則如下。

remote_ip:remote_port:port

但是你放錯了變量。 修改語法如下:

ports:
    - ${APP_PORT}:80

ports:
    - ${FORWARD_DB_PORT}:3306

而在dotenv文件中,對於Integer類型的變量,不需要雙引號,也可以更正一下。

APP_PORT=8080
FORWARD_DB_PORT=3307

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM