docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.87k stars 291 forks source link

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

Open jorisdonkers opened 1 year ago

jorisdonkers commented 1 year ago

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

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.

ddokleja commented 1 year ago

Same issue for me, Docker on MAC version 4.16.2

jorisdonkers commented 1 year ago

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

kreef19 commented 1 year ago

Still a problem in v4.17.1

mejobloggs commented 1 year ago

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😅

jorisdonkers commented 1 year ago

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 commented 1 year ago

Still a problem in v4.20.1

henriquemaran commented 1 year ago

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.

RobTranquillo commented 1 year ago

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.

cmrn-rhi commented 1 year ago

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.

contra1337 commented 1 year ago

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

zhtiyissr commented 1 year ago

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

djc5166 commented 1 year ago

Same here,

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

officialrizwanali commented 1 year ago

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.

LandyZhu commented 1 year ago

Same problem, 4.24.2 (124339) , Windows 22H2

arlight1 commented 1 year ago

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

francescoavant commented 1 year ago

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

BariZ44 commented 1 year ago

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.

xlturing commented 1 year ago

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

bsousaa commented 1 year ago

Can you share detailed steps to reproduce the issue?

kand7dev commented 1 year ago

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.

jez-moxmo commented 1 year ago

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

ZYinMD commented 1 year ago

@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.

kand7dev commented 11 months ago

@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.

nowshadk07 commented 11 months ago

Any solution yet? I am facing the same issue.

kand7dev commented 11 months ago

@nowshadk07

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

network-charles commented 10 months ago

docker run -it

edsonmendieta commented 10 months ago

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).

TemoSulava commented 9 months ago

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

lucaterribili commented 8 months ago

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

jorisdonkers commented 7 months ago

Still a problem in docker desktop v4.28.0.

JosephNgabo commented 7 months ago

still having the same problem on the docker version 25.0.3,

Nabeelaron commented 7 months ago

issue for me as well - v4.26.1

PhiliaTheCat commented 6 months ago

ver 4.30.0, still the same issue

back2sqr1 commented 6 months ago

Same issue, on 4.30.0 linux

vqthkvnn commented 5 months ago

Same issue, on 4.30.0 window. This problem has never happened before version 4.27.1

erdgrbz commented 5 months ago

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

you need to run it from cli for the first time, after that desktop app works.

this got me confused since i am a beginner

nicobenito commented 5 months ago

Sill a problem on 4.31 on mac m1. running the container with -it first works and it allows to run it on the app afterwards

samisamiuddin55 commented 5 months ago

I had to create a new container using CLI and it worked.

Then I could stop/start it from both CLI and GUI.

On the other hand creating a new container via GUI and then starting it via GUI/CLI didn't work. Exited with code 0.

abkds commented 4 months ago

Still an issue on docker 4.32.0 on mac m1 even doing -it to run a container and then coming back to it later doesn't work

erambeau commented 4 months ago

Still an issue on 4.32.0, Windows 11. Images: Debian (latest, stable) and Ubuntu (latest).

The workaround of initializing the container with docker run -it <image id> seems to work, but it defeats the purpose of having a UI with Docker Desktop. Moreover, the terminal is in beta, so we shouldn't have to resort to such a workaround to make it work.

loginetsolutions commented 4 months ago

4.32.0 and still not fixed

kamesh-git commented 4 months ago

i'm using v4.33.0 in win10 and the issue continues😔. Why docker is not resolving the issue?

stinklewinks commented 3 months ago

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.

This was a workaround for me. Maybe something with the desktop app

imalishahzadk commented 2 months ago

I have installed 4.33.1. i pulled node image, and when i run it from docker desktop, it exited with code 0. same for php image.

Jimmynycu commented 1 month ago

Still happen in v4.34.4

nishan1281 commented 3 weeks ago

Use the following command:

docker run -it your-docker-image-name sh

Example: docker run -it hello-docker sh

This worked for me to keep the container running.

Note: It is my first day.