Sunday, October 9, 2022

[SOLVED] Additional property port is not allowed in docker compose

Issue

I am trying to run my docker-compose.yaml file on aws ec2 instance but I keep getting this error

services.postgres Additional property port is not allowed

My YAML file

version: "3.8"
services:
    java-maven-app:
        image: oshabz/docker-demo:1.1.0-25
        ports:
            - 8080:8080
    postgres:
        image: postgres:13
        port:
            - 5432:5432
        environment:
            - POSTGRES_PASSWORD=my-pwd

Solution

You need to use the property ports not port - as you have done with the java-maven-app service. So your postgres service should look like (use ports not port)

    postgres:
        image: postgres:13
        ports:
            - 5432:5432
        environment:
            - POSTGRES_PASSWORD=my-pwd


Answered By - neonwatty
Answer Checked By - Willingham (WPSolving Volunteer)