PyCharm Docker Compose Debug Django - debugging

I've followed Jetbrains tutorial for setting up Docker Compose with remote python interpreter on Mac OS
https://www.jetbrains.com/help/pycharm/using-docker-compose-as-a-remote-interpreter.html#debug
Everything works well - starting and composing services, manage.py commands etc. apart from debugging. Pycharm just won't stop on specific breakpoint and prints in PyCharm status bar - "Waiting for connection"
Did anyone experienced same issue?

This has happened to me, running docker network prune (to force docker to remap ips), then doing "invalidate cache and restart" has worked for me.

Related

Why docker desktop is unable to start docker-backend?

Problem:
I started my system as usual but my docker-desktop doesn't work, WSL doesn't respond to commands and there is a process called "Vmmem" using 25% of my memory. I have tried a bunch of thing but nothing seems to work.
System Attributes:
Windows 10 Pro (10.0.19045.2486)
docker: 4.15
WSL: 1.0.3.0
More context:
Recently I was having trouble with my docker set up. I have one particular container that was "crashing" the docker. It was not throwing any exception but after some event (that I couldn't find out) all the other container where unreachable any attempt to stop/start another container would result on "Error: 500 failed to respond...". When this happens I usually just restart the system and everything works fine, but today it wasn't the case. I restarted and I noticed that I had the "Vmmem" process already running at 25% (it usually just reaches this point at the end of the day), the docker desktop could not start the docker backend and when I tried running wsl -l -v I got no response. I can use some docker commands like docker -v but the docker compose up doesn't work at all.
What I've tried:
restart the system again (nothing changed, still starting with 25% mem usage)
deactivating Hyper-V (nothing happened)
stop/start docker service using net start/stop <service> (it gives a response but didn't solve the problem)
Uninstall docker-desktop (it crashes before even starting the uninstall process)
Terminate WSL wsl -t Ubuntu (got no response from wsl)
Overwrite installation with Docker 4.16 (it gets stuck on "Preparing for update... / Stopping VM and preparing for update")
Forcefully kill the "Vmmem" (I've got Access denied error)
Edit 1:
I managed to finally install the Docker desktop 4.16 but the problem continues, system starts with 25% Vmmem memory usage and docker desktop is not able to initiate backend.
the process Vmeem It represents the memory and CPU consumed by the combination of all the virtual machines running on your Windows PC, there is a possibility that processes are still running on your PC. I recommend you try to launch these commands from the console:
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
This will stop all containers and delete them.
If this doesn't work, I recommend you enter your bios settings and disable virtualization, that way those processes will stop, then you can enable it again and try. I wish you luck and I hope this resolves.
Steps that I did to be able to stop "Vmmem" process and install docker desktop again:
disable Hyper-V
disable virtualization (BIOS)
restart system
to this point the "Vmmem" problem was gone
uninstall docker desktop
rm all wsl instances
enable Hyper-V
enable hypervisorlaunchtype
restart system
enable virtualization (BIOS)
install wsl Ubuntu instance
install Docker Desktop
Maybe some steps listed here are redundant but that is what I did. hope it helps if other people is passing through the same problem

Docker runs on getting started dashboard but not on PS Terminal (or any other)

When I first install docker I can choose to go to the Quick Start Guide interactive window (or once done the quick start guide I can also go there again by right clicking on docker icon and selecting Quick Start Guide on the menu). As you can see I can do anything docker in this windows/environment as shown:
as you can see I can pull containers, run containers right there on that quick start guide command line, however, when I open a terminal (be it PS or Git or normal windows CMD) I can't seem to run docker there as shown:
So not so sure what am I missing. Thanks for any feedback!
I found the solution at least to my situation, problem is that there was this environment variable DOCKER_HOST (left over from Docker Tools) that was being set, which is not set when I do the quick start guide. Solution was to remove this environment variable from system/user settings and voila I could run docker on the terminal.

Cannot find the docker container running on port 80, tried everything usual

What happened:
I ran a container (vuejs-build website on a httpd:2.4) from shell (oh my zsh) on mac OS 11.2.2 using the previous docker release.
Then I updated the mac OS docker desktop.
Now the container is running but it's not showing on docker ps -a or docker container ls -a. I cannot find the process no matter what I try. Tried all the ps aux commands with grep, all lsof -wahtever, finding it in activity tool on mac. Even restarting the mac or stopping docker deamon does not stop it.
Has anybody a clue how to find it? I can open and refresh the webpage that is running in the container.
Docker version now says: Docker version 20.10.5, build 55c4c88.
PLEASE HELP!!
I solved it myself:
The container was stuck but restart seemed to have actually killed it.
However:
I realized that assets such as images are not being loaded despite JS and CSS is.
So I tried starting another httpd instance with docker run -p 80:80 httpd and reloaded. Firstly the same site as before appeared. But being able to start another httpd got me thinking.
The I opened dev tools in my browser. That disables Cache (using Chrome). Another hit on refresh then showed the "It works" page from httpd.
Some researching gave me the following theory: Vuejs stores the compiled Markup, JS and CSS on your browsers persistence storage. Probably for performance.

OSX X11 Error cannot open display

I am trying to run any GUI container I can on MacOS. With every container I try (firefox, chrome, tor, spotify, etc) I always get the error Error: cannot open display. And it's not specific to the docker run command where I pass the environment flag with my $DISPLAY. When I try to run xhost + I get the same error.
I have a fresh XQuartz installation. It is up and running. I have turned on "allow connections from network" under security. I've tried building my own images and pulling jessie frazelle's images. I do not suspect it is a docker issue or the Dockerfiles. It is something on the host, my laptop. I can't seem to figure out what it is.
MacOS Sierra 10.12.5
Docker 17.12.0 Stable
XQuartz 2.7.11 (xorg-server 1.18.4)
My local's $DISPLAY is set to :0.0
So I finally got this to work. And it seems it was pretty simple. I am not certain how this actually fixes the issue, but now the containers work.
How I fixed it was opening up XQuartz and then opening up the "Terminal" app from the "Applications" menu. Then running the command export DISPLAY=192.168.1.X:0, then xhost +. It outputted something like this "access control disabled, clients can connect from any host". After that I was able to run my docker run commands to launch the desired GUI containers.
I am still uncertain how this works and not running them from my laptops Terminal app, but it worked. It must be something I have set in my local env. Hopefully this helps someone else out who may be running into the same issues.
Based on #Byron's answer, I've found out that I could get it to work by running these 2 commands in the normal terminal:
export DISPLAY=:0
/opt/X11/bin/xhost +

How to I make docker start as a service on OS X?

I installed DockerToolbox 1.11.1 on my Mac OS 10.11 and it does start docker via Kinematic and if I click Docker CLI it wills start a terminal where docker is properly running (docker version returns info and success).
Still, If I try to do the same from normal console it does fail to detect docker and I do want to have docker available in any console window, starting it at login time, automatically or on demand. Still, once started I expect to be able to use it from any console.
I guess that this part was missing from the tutorials and I would like to find a solution for it. How can I do this?
This is what docker machine is for. Your docker instance is running in a virtual machine, and you have to set a few environment variables to connect to it(DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH and DOCKER_MACHINE_NAME) . If you run eval $(docker-machine env [machine name]) this will set those variables automatically for you assuming the VM is up. You could then put that line into your bash profile for automatic setup.
Check out the docs here https://docs.docker.com/machine/overview/
Also, there is a native version of Docker for OSX (currently in limited beta) which removes the need for docker machine, so hopefully in the near future none of this will be necessary.
I was able to come up with some code that works across all tested platforms, including OS X:
docker version > /dev/null || {
# that's in case docker machines is the the current one (OS X)
eval "$(docker-machine env default)"
}
# keep this here, it will return an error code if docker is not usable
docker version

Resources