how do you quit docker-compose up # macOS? - macos

after docker-compose up, on windows i quit that with "CTRL+C" and the container(s) are still running. When i do this on my mac, then docker kills my container :(
I tried it now with a shell script, which executes the docker-compose up into "echo", but on some container, the scripts hang up.
How do you do that? Are there any best practices? (suitable with windows)
Thanks a lot.

If you want to run docker-compose up and leave the process running without being attached to your terminal, you can run it in detached mode with docker-compose up -d.
https://docs.docker.com/compose/reference/up/
After doing so, you'd have to use docker-compose stop or docker-compose down to stop your running containers, since CTRL+C won't kill them.

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

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.

How to restart Docker-for-mac with command?

I'm using Docker for mac.
I'd like to restart this Docker-for-mac App with command on Terminal.
What's the command?
There was no documentation for this.
I had do restart it by clicking that button anytime that I needed to.
Forcing Docker for Mac to re-read its config with
killall -HUP com.docker.hyperkit
might work - if it doesn't, please explain in more detail why you need to restart Docker in the first place.
For me I needed to restart Docker so I could install the new version
killall Docker did the trick.

How can I keep a docker debian container open?

I want to use a debian Docker container to test something, and by this I mean execute some commands in the debian bash console. I tried downloading the image using docker pull debian and then running it using docker run debian, but I get no output. What am I doing wrong? Shouldn't the docker container stay open until I close it?
You need to explicitly run bash:
docker run -it debian /bin/bash
The -i means "run interactively", and -t means "allocate a pseudo-tty".
A good place to read a bit more is the section Running an interactive shell in the Quickstart documentation.

What is the command/configuration to run NodeJS/Express app as a daemon?

In SSH if I run:
$ node server
My web app works fine until I close the SSH session. What is the command or configuration needed so that it runs all the time without an active SSH session?
you can run it like:
nohup node server
Or you can install forever.
npm -g install forever
forever start server
If you have multiple nodejs, you can use pm2 to manage them.
Or, use screen or tmux to keep the nodejs running while detach the session.

Resources