2

I'm running Docker Desktop 4.2.0 on Windows 10 Pro.

Until recently, to detach from containers after running docker-compose up, I could use the keyboard shortcut CTRL + z. This stopped working. How to fix it?

I know I can run docker-compose up -d and docker-compose logs -f but would prefer to use the original way. Other answers I found on stackoverflow suggest CTRL + p, CTRL + q or CTRL + \ but neither works.

8ctopus
  • 183

2 Answers2

2

I'm not sure there will be a key sequence to detach from docker-compose (or docker compose). The <ctrl>-p <ctrl>-q sequence is intended for detaching from containers you are attached to with stdin (and may also require a tty connection). Since compose is starting multiple containers and then showing the logs of those containers when you don't use the -d option, you're not really attached to "a container".

The <ctrl>-z sequence is a shell command, e.g. in bash, that suspends the job and sends it to the background. You can view background jobs with the jobs command, and either leave them running in the background with bg or return to the foreground with fg. This isn't specific to docker or docker-compose.

My typical advice is if you don't want to remain attached, then use the docker-compose up -d option, and to view the logs use docker-compose logs. This is because in the foreground, docker-compose is trying to act like a foreground daemon that exits what it's doing when stopped, which includes all containers that it created.

BMitch
  • 2,302
  • 11
  • 15
-1

Actually played with this again today and found a way to achieve what I want:

start /B docker-compose up

which is the Windows command line equivalent of Linux

docker-compose up &
8ctopus
  • 183