devcontainers / templates

Repository for Dev Container Templates that are managed by Dev Container spec maintainers. See https://github.com/devcontainers/template-starter to create your own!
https://containers.dev/templates
MIT License
1.02k stars 262 forks source link

Error: Conflicting options: port publishing and the container type network mode with IntelliJ #273

Open dieter-medium opened 3 months ago

dieter-medium commented 3 months ago

I encountered an error with port publishing and the container type network mode while using IntelliJ. It seems to be related to the network mode setting.

Error: conflicting options: port publishing and the container type network mode

The issue seems to occur due to the network mode configuration in the docker-compose.yml. Specifically, in javascript-node-postgres and simalar.

The error is resolved if the network_mode setting is switched between app and db services. For instance, instead of using network_mode: service:db within the app, using network_mode: service:app within db resolves the error.

References:

[YouTrack Issue](https://youtrack.jetbrains.com/issue/IJPL-65932/Devcontainers-Error-response-from-daemon-conflicting-options-port-publishing-and-the-container-type-network-mode)
chrmarti commented 2 months ago

Doing it the other way around had the following issue: https://github.com/microsoft/vscode-dev-containers/issues/537.

dieter-medium commented 2 months ago

This issue might explain why some developers choose to use:

services:
  network_manager:
    image: alpine:latest
    command: ["sleep", "infinity"]  # Keeps the container running

   app:
    ...
    network_mode: service:network_manager

It's an interesting approach to managing shared network environments in Docker Compose. Perhaps IntelliJ will improve its support for this pattern in the future.