docker-archive / compose-cli

Easily run your Compose application to the cloud with compose-cli
Apache License 2.0
956 stars 253 forks source link

error decoding 'Ports': Invalid containerPort: 8080 #2218

Closed dsha256 closed 1 year ago

dsha256 commented 1 year ago

When I'm trying to run docker compose up or docker compose up --build commands, I get the following error:

1 error(s) decoding:

* error decoding 'Ports': Invalid containerPort: 8080

This is my Docker file's content:

# Build stage
FROM golang:1.19-alpine AS builder

RUN apk add --no-cache
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN CGO_ENABLED=0 go build -o ./bin/main ./cmd/api/main.go

# Run stage
FROM alpine:3.16

RUN apk add --no-cache

RUN mkdir /plfa
WORKDIR plfa

RUN adduser dsha256 --disabled-password --no-create-home
RUN chown -R dsha256:dsha256 /plfa
RUN chmod -R 755 /plfa

COPY --from=builder ./app/bin/main ./
COPY --from=builder ./app/.env ./
RUN   export $(grep -v '^#' .env | xargs -d '\n')
CMD [ "./main" ]

USER dsha256

This - docker-compose.yml

version: "3.8"
services:
  pragmatic_live_feed_aggregator:
    build:
      context: .
      dockerfile: ./Dockerfile
    restart: always
    env_file:
      - .env
    ports:
      - "${SERVER_PORT}:${SERVER_PORT}"

Here's the SERVER_PORT definition from my .env file:

SERVER_PORT=8080

What is the problem with these files?

I did some research and in most cases, the problem is caused by incorrect syntax or extra spaces, but in my case, everything seems like correct in that perspective.

dsha256 commented 1 year ago

Well, I'm using WSL 2. Just closed the terminal then opened it again and everything worked 😄