简体   繁体   English

错误:撰写文件“./docker-compose.yml”无效,因为:services.mysql.ports 无效

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

ERROR: The Compose file './docker-compose.yml' is invalid because: services.mysql.ports is invalid: Invalid port ""3307":3306", should be [[remote_ip:]remote_port[-remote_port]:]port[/protocol]错误: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. 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 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 ** **.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

In docker-compose, the rule for mapping ports is as follows. docker-compose中端口映射规则如下。

remote_ip:remote_port:port

But you misplaced the variables.但是你放错了变量。 Modify the syntax as follows:修改语法如下:

ports:
    - ${APP_PORT}:80

ports:
    - ${FORWARD_DB_PORT}:3306

And in the dotenv file, for variables of Integer type, you do not need to double quote, correct them as well.而在dotenv文件中,对于Integer类型的变量,不需要双引号,也可以更正一下。

APP_PORT=8080
FORWARD_DB_PORT=3307

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM