PyCharm 2022.1 docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings
My docker-compose file
version: "3"
services:
python:
image: python:3.9-slim
container_name: python
network_mode: "host"
My operating system is Ubuntu 22.04
I am using VPN to connect to AWS RDS service and I want to share host network with the container. I am getting an error when I wan to use PyCharm debugger.
How can I solve this issue?
Please sign in to leave a comment.
Hi,
A bit more information about your environment would help to reproduce/identify the issue. Where is the docker daemon located? How do you connect to it?
Hi,
Thanks for your effort, I really need a help. If you need any kind of information, just say it and will send to you ;)
The output of docker info command is below:
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
compose: Docker Compose (Docker Inc., v2.6.0)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 5
Running: 2
Paused: 0
Stopped: 3
Images: 52
Server Version: 20.10.17
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version: v1.1.2-0-ga916309
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
cgroupns
Kernel Version: 5.15.0-43-generic
Operating System: Ubuntu 22.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 30.59GiB
Name: CN-PC26L5MH
ID: 4EFC:BBD7:UZ7M:E4H5:QWL4:AHZE:2PXP:POAT:2SET:L4SL:KAR5:BFMF
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Setting an interpreter in PyCharm
File --> Settings
When I add a local compose interpreter using your Dockerfile...
... and run a simple for loop for the test...
The debugger is working and I can stop at the breakpoint.
Could you please try this simple test as well? Does the issue reproduce? If so, please provide a screenshot of your Docker settings from [Preferences | Build, Execution, Deployment | Docker]
Also, please test this in the latest Release Candidate build.
Thanks, It works! :)
I would like to ask a little bit about running a python code as the module using a python interpreter. I'm getting an error and I want to ask how can I set up my environment without the script path? ;)
You can specify module name instead of script path, see the first parameter in https://www.jetbrains.com/help/pycharm/run-debug-configuration.html#run-debug-parameters
Thanks, it helped. The error message disappeared but breakpoint doesn't work. When I tried to run my module using the debugger, the PyCharm didn't stop at the specified breakpoint.
Is it possible to create a minimal project sample to reproduce the issue? Either way, I suggest reporting this issue to https://youtrack.jetbrains.com/issues/py with the following information:
- Minimal project sample, if possible
- Please add `PYCHARM_DEBUG=True` environment variable to your run/debug configuration, reproduce the issue and provide the full debug console output
- Logs from **Help | Collect Logs and Diagnostic Data**