'docker-compose up; ERROR: 'network_mode' and 'networks' cannot be combined

After rebuild .jar file, and rebuild docker image, i try to docker-compose up, then i have error ERROR: 'network_mode' and 'networks' cannot be combined

This is docker-compose.yml file

version: "3"
services:


  postgres:
    image: postgres:latest
    restart: always
    container_name: postgresdb
    ports:
      - 5432:5432
    environment:
      - POSTGRES_PASSWORD=admin
      - POSTGRES_USER=postgres
      - POSTGRES_DB=postgres
    volumes:
      - ./tables.sql:/docker-entrypoint-initdb.d/shema.sql
    networks:
      - rent-manager-network


  rent-service-manager:
    image: rent-service-manager
    network_mode: bridge
    container_name: rent-manager-app
    ports:
      - 8080:8080
    environment:
      SPRING_DATASOURCE_URL: ${POSTGRESS_URL}
    restart: always
    depends_on:
      - postgres
    networks:
      - rent-manager-network

networks:
  rent-manager-network:
    driver: bridge

Dockerfile:

FROM openjdk:11.0.1-slim as builder

ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar

RUN java -Djarmode=layertools -jar application.jar extract

ENTRYPOINT ["java", "-jar", "application.jar"]


Solution 1:[1]

Please remove network_mode: bridge from the rent-service-manager service.

You don't need it when your network is bridged.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Søren Hansen