for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Docker desktop will exit(0) docker container immediately after running.

Open jorisdonkers opened this issue 2 years ago • 44 comments

  • [x] I have tried with the latest version of Docker Desktop
  • [x] I have tried disabling enabled experimental features
  • [ ] I have uploaded Diagnostics

Actual behavior

When running a docker image it will immediately exit after running with exit code 0. In previous versions of Docker desktop this was not the case. It looks like Docker desktop used to run all docker containers with the -it flag but not anymore. I'm using Docker desktop version 4.16.3. I can't find any information about it in the release notes. Is this intended or is this a bug?

As a side note I want to add that containers that already exist do not have this problem. It only occurs when creating a new container from a docker image when clicking on run within Docker desktop.

Reverted to docker desktop version 4.13.0 and everything works as expected again.

Expected behavior

That docker containers keep running after pressing play.

Information

  • Windows Version: Windows 10
  • Docker Desktop Version: 4.16.3
  • WSL2
  • Are you running inside a virtualized Windows e.g. on a cloud server or a VM: no

Output of & "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

PS C:\Program Files\Docker\Docker\resources> .\com.docker.diagnose.exe check [2023-02-15T13:40:35.026371300Z][com.docker.diagnose.exe][I] set path configuration to OnHost Starting diagnostics

[PASS] DD0027: is there available disk space on the host? [PASS] DD0028: is there available VM disk space? [PASS] DD0002: does the bootloader have virtualization enabled? [SKIP] DD0018: does the host support virtualization? [PASS] DD0001: is the application running? [PASS] DD0022: is the Virtual Machine Platform Windows Feature enabled? [PASS] DD0021: is the WSL 2 Windows Feature enabled? [PASS] DD0024: is WSL installed? [PASS] DD0025: are WSL distros installed? [PASS] DD0026: is the WSL LxssManager service running? [PASS] DD0029: is the WSL 2 Linux filesystem corrupt? [PASS] DD0035: is the VM time synchronized? [PASS] DD0017: can a VM be started? [PASS] DD0016: is the LinuxKit VM running? [PASS] DD0011: are the LinuxKit services running? [PASS] DD0004: is the Docker engine running? [PASS] DD0015: are the binary symlinks installed? [PASS] DD0031: does the Docker API work? [PASS] DD0013: is the $PATH ok? [PASS] DD0003: is the Docker CLI working? [PASS] DD0005: is the user in the docker-users group? [PASS] DD0038: is the connection to Docker working? [PASS] DD0014: are the backend processes running? [PASS] DD0007: is the backend responding? [PASS] DD0008: is the native API responding? [PASS] DD0009: is the vpnkit API responding? [PASS] DD0010: is the Docker API proxy responding? [PASS] DD0006: is the Docker Desktop Service responding? [SKIP] DD0030: is the image access management authorized? [PASS] DD0033: does the host have Internet access? [PASS] DD0002: does the bootloader have virtualization enabled? [PASS] DD0018: does the host support virtualization? [PASS] DD0001: is the application running? [PASS] DD0022: is the Virtual Machine Platform Windows Feature enabled? [PASS] DD0021: is the WSL 2 Windows Feature enabled? [PASS] DD0024: is WSL installed? [PASS] DD0025: are WSL distros installed? [PASS] DD0026: is the WSL LxssManager service running? [PASS] DD0029: is the WSL 2 Linux filesystem corrupt? [PASS] DD0035: is the VM time synchronized? [PASS] DD0017: can a VM be started? [PASS] DD0016: is the LinuxKit VM running? [PASS] DD0011: are the LinuxKit services running? [PASS] DD0004: is the Docker engine running? [PASS] DD0015: are the binary symlinks installed? [PASS] DD0031: does the Docker API work? [PASS] DD0032: do Docker networks overlap with host IPs? No fatal errors detected.

Steps to reproduce the behavior

Klick on run of an docker image in the images tab in docker desktop.

jorisdonkers avatar Feb 15 '23 13:02 jorisdonkers

Same issue for me, Docker on MAC version 4.16.2

ddokleja avatar Mar 03 '23 12:03 ddokleja

Just updated Docker desktop to v4.17.0, the issue is still there.

jorisdonkers avatar Mar 03 '23 16:03 jorisdonkers

Still a problem in v4.17.1

kreef19 avatar Mar 28 '23 13:03 kreef19

It is my first time trying docker/desktop. I installed using defaults and wsl2. Download the official ubuntu image and clicked run. It exists immediately and I can't find why.

I think I picked the wrong time to start learning this docker thing😅

mejobloggs avatar Apr 05 '23 03:04 mejobloggs

It is my first time trying docker/desktop. I installed using defaults and wsl2. Download the official ubuntu image and clicked run. It exists immediately and I can't find why.

I think I picked the wrong time to start learning this docker thing😅

As a workaround you can try running the docker container through powershell.

docker run -it --name ubuntu ubuntu:latest

After running it once in powershell you can start and stop it via docker desktop with no issues.

jorisdonkers avatar Apr 05 '23 12:04 jorisdonkers

Still a problem in v4.20.1

jorisdonkers avatar Jun 16 '23 12:06 jorisdonkers

Still a problem in v4.22.0.

@jorisdonkers workaround worked for me:

It is my first time trying docker/desktop. I installed using defaults and wsl2. Download the official ubuntu image and clicked run. It exists immediately and I can't find why. I think I picked the wrong time to start learning this docker thing😅

As a workaround you can try running the docker container through powershell.

docker run -it --name ubuntu ubuntu:latest

After running it once in powershell you can start and stop it via docker desktop with no issues.

henriquemaran avatar Aug 11 '23 13:08 henriquemaran

Same problem here with a first time installed Docker Desktop on Windows 11. An image started running via DD exiting immediately, but the only one that is created via the docker run -it --name ubuntu ubuntu:latest (thanks @jorisdonkers) works.

I'am on Win11, WSL was installed long before, maybe as the system was an Win10 and being used couple of times. Tried lots of images in DD Ubuntu, Debian, Alpine in different releases and with different running options, but all are failing. Machine is a AMD Ryzen 7 4800H, Virtualization is activated. With 32GB Ram.

RobTranquillo avatar Aug 23 '23 07:08 RobTranquillo

Also having he same issue. Windows 10 Home (22H2) recent reformat, virtualization enabled, new install of WSL, WSL2 features enabled, and Docker Desktop (4.22.1). Only able to get @jorisdonkers solution to work, but any other container I try to run exits within seconds.

cmrn-rhi avatar Sep 08 '23 22:09 cmrn-rhi

Also have this issue, V4.23.0. Creating the container from the image within the docker desktop app doesn't work, but creating it from terminal then running in the app works like others have said

contra1337 avatar Sep 27 '23 04:09 contra1337

same problem, docker desktop: v4.24.0, os: Apple M1 Sonoma v14.0

zhtiyissr avatar Oct 11 '23 02:10 zhtiyissr

Same here,

The docker run command generated by the GUI is missing -it now, running my own docker run in the terminal works.

djc5166 avatar Oct 12 '23 01:10 djc5166

I'm facing the same issue, tried 4.23 and now the latest one 4.24.1.

Containers created using UI exit immediately without any logs displayed, with exit code 0.

but, I can create containers with CLI and they're running.

Containers created using UI don't even run with CLI.

officialrizwanali avatar Oct 12 '23 07:10 officialrizwanali

Same problem, 4.24.2 (124339) , Windows 22H2

LandyZhu avatar Oct 13 '23 07:10 LandyZhu

Having the same issue here, just get exit(0) immediately and can't interact like if I launched it at the cli.

arlight1 avatar Oct 13 '23 17:10 arlight1

Same issue here. 4.24.2 (124339), Windows 11 Pro 22H2

francescoavant avatar Oct 16 '23 20:10 francescoavant

Containers created using Docker Desktop exited immediately without any logs displayed, with exit code 0. I can create containers with CLI and they're running and can manage them in GUI (Start-Stop). Containers created using GUI don't even run with CLI.

BariZ44 avatar Oct 17 '23 09:10 BariZ44

same issue still here. macOS 13.1, docker version 4.24.2, engine 24.0.6.

xlturing avatar Oct 26 '23 03:10 xlturing

Can you share detailed steps to reproduce the issue?

bsousaa avatar Oct 26 '23 10:10 bsousaa

Can you share detailed steps to reproduce the issue?

From the Docker Desktop Application just a pull an Image and click on Run at the top right corner.

kand7dev avatar Oct 26 '23 23:10 kand7dev

they told me that docker would solve all my problems and now threer hours later jI am going to scream

jez-moxmo avatar Nov 03 '23 07:11 jez-moxmo

@bsousaa In docker desktop, in the search box, type ubuntu, then click "run" - that's how to reproduce.

It's not a bug, but a pop up in the GUI explaining what actually happened would be nice, because new people have a misconception, they expect to spin up a ubuntu VM, like what WSL does.

I think the misconception comes from the very first container "welcome-to-docker" (most of us probably have forgotten about it, but it's an example container everybody automatically gets when installing Docker Desktop). That container is a long running server that they can ▶ and ⏹.

May also consider adding a course in the learning center of a container that does a job then exits. Imo it should be the 4th course in the list.

ZYinMD avatar Nov 08 '23 16:11 ZYinMD

@bsousaa In docker desktop, in the search box, type ubuntu, then click "run" - that's how to reproduce.

It's not a bug, but a pop up in the GUI explaining what actually happened would be nice, because new people have a misconception, they expect to spin up a ubuntu VM, like what WSL does.

I think the misconception comes from the very first container "welcome-to-docker", which is a long running server that they can ▶ and ⏹.

May also consider adding a course in the learning center of a container that does a job then exits. Imo it should be the 4th course in the list.

That's what newcomers expect. They have no idea about container flags and which ones to use, how do we attach to a running container and more.

kand7dev avatar Dec 06 '23 12:12 kand7dev

Any solution yet? I am facing the same issue.

nowshadk07 avatar Dec 24 '23 09:12 nowshadk07

@nowshadk07

The only solution is to manually start/run those containers/images if you want to interact with them using the -it flags.

kand7dev avatar Dec 27 '23 00:12 kand7dev

docker run -it <image_name>

network-charles avatar Jan 08 '24 21:01 network-charles

Yeah "docker run -it [image_name]" is what worked for me like the two people above me also said. (square brackets are not to be included in the actual command, just fyi).

edsonmendieta avatar Jan 18 '24 22:01 edsonmendieta

I can run docker image via cli command docker run -it --name [image] [image]:latest, and it also shows as running in the GUI, but can never run any container using the GUI itself, it insta exits. Guess we got to stick to using cli only on win wsl

TemoSulava avatar Feb 07 '24 10:02 TemoSulava

So, if i have to use terminal to run a container...what is the sense of this application?

lucaterribili avatar Mar 26 '24 16:03 lucaterribili

Still a problem in docker desktop v4.28.0.

jorisdonkers avatar Apr 04 '24 08:04 jorisdonkers