If the mac wakes up after hibernation, the services started by docker will all hang up and will be started one by one. It is very troublesome. Does a great god know how to set it up?
I have never encountered a similar problem before I saw this problem, and then after I saw this problem …
I have a MacBook Pro that I keep in the company for a long time. It closes every day after work. I have never encountered the problem of Docker hanging up automatically. So when I first saw this problem, my heart refused.
As a result, I have encountered the same problem miraculously on my MacBook at home these two days. Sleeping for a short time is fine, but if you stay overnight, the next day
docker psIt’s empty. I didn’t care at first. I thought I just forgot to start the service. I noticed the problem the second time I saw it on the timeline.
Then I specially tested it for two days. Sure enough, after a long sleep, Docker will automatically hang up and all services will quit. I checked all the settings and versions and there was no problem.
I tried to search and found that there were still many people reporting similar problems, but they all focused on macOS 10.10. GitHub has a lot of discussions, but there seems to be no definite conclusion. Moreover, these discussions have been going on for a long time, more than a year now, and my macOS and Docker for Mac are the latest versions, so these discussions are not helpful.
The only thing that is more helpful is that someone has provided onePrevent Mac from going to sleepHowever, it was too violent and I didn’t try it if I didn’t like it.
But this method gave me an inspiration.
Since my other MacBook Pro has been used for so long without any problem, this MacBook has only recently encountered a problem. The system and software version, settings, images, container, etc. between the two Macs are the same. The only difference is that recently I used the MacBook for external display, so I used it.Apple’s official USB-C to HDMI adapter.
In other words, in these days, my MacBook is not directly connected to the power supply, but connected to the power supply and HDMI through a patch cord. So I did an experiment last night, pulling out the adapter and connecting the power directly to the Mac. Just before writing this answer, I checked it almost 20 hours before I closed it last night.
docker psAnd guess what?
Everything is normal.
After finding this, I will write the answer. I don’t know how to explain this phenomenon. All I know is that my MacBook can be directly connected to the power supply, otherwise the docker will hang up after a long sleep.
I guess it may have something to do with MacBook’s power management? The only difference in the settings of my MacBook is that Power Nap is turned on when the power is supplied and not when the battery is supplied. I can be sure that the Mac can correctly identify whether the power is supplied by the power source by connecting the adapter to the power source, but who knows if there will be any bug during sleep?
I hope it will be helpful to the subject.