This is my first time using Docker. I have installed Docker Desktop in Windows 10. I have the WSL 2 running. I have no problems downloading and running the image. However, as soon as I run the image, it creates a container but exits immediately with an error code of 0.
I have checked the log, inpsected, etc… The log files contain nothing. However, when I go to “Files” and says, “An error has occurred while refreshing the container files” I am not sure if this is the reason.
Also, I have tried to run it via command line docker run <container_id> and docker run -it <container_id> and it spawns a container and it runs. I just need to know how to do this from Docker Desktop?
Any help would be appreciated.
Sure, we can give it a try
Please share the exact commands you used to start your containers and the container logs, so we can actually see what you did and how you did it.
The images run fine via command line or DD. When the image creates a container
From command line, I grab a container using
bash docker pull node I have no problems doing this through DD either.
The only way to launch a container and have it run, is using switches
bash docker run -it <image_id> without the switches it creates a container but it will not run. Not even through DD. It just exits immediately. I want to be able to do this through Docker Desktop as well.
I’ve also tried
bash docker start <container_id> and that doesn’t work. It doesn’t give me an error message.
For the logs, I just open the logs from Docker Desktop but they are empty.
I just want to be able to run a container from DD, instead of command line. But I click on “run” and it gives me the status of ‘exited’
Also, when I create the container by running
bash docker run -it <image_id> I can then stop and run the container it created with DD.
I am not sure how your response matches what I asked in the last post
Share the commands in a way, so that I am able to copy/paste them into a terminal and see what happens. I need the actual command, to reproduce the same problem.
I don’t understand what you meant. What is it you need from me?
I updated the previous post. Seems you were already typing your answer while I updated the post.
It seems to work with other packages but not with others. Let me check into this and get back to you.
Thanks for your help.
I tried to install Alpine with the DD. It pulled it in fine but when I click on the run icon, it just stopped as “exited”.
When I pull the image and run the image from command line
bash docker run -it <image_id it runs the image and launches a container. This time, the container runs, even if I decide to stop and start it again.
This is where I am stumped.
-it (which is the same as
-ì -t) the
-t attaches a pseudo terminal to the container, which keeps the container running even if there is no foreground process running.
When I asked for exact commands, I was referring to something like this:
docker run -d -e required_var1=configures_something -e required_var2=configures_something_else -v persist_data:/path/in/container alpine
This would allow seeing that you are trying to use a base image, which of course would immediately terminate, as it has no foreground process that keeps running. Your
docker run -it command attaches a terminal to the container, which keeps the container running. Usually application images have an entrypoint script that does some sort of preparation work and then starts a foreground process that keeps the container running, until this foreground process in the container stops.
- You neither install images, nor containers → you pull images into the local image cache.
- You do not run images → you create and run containers based on images.
- Each container bases on the exact image used to create it.
- A container is just a process (which can have child processes) in an isolated environment.
- If no foreground process remains running in a container, the container terminates.
As a beginner, never just describe what you do, instead share the exact commands you use, so that others can reproduce it. Typically, the problems are hidden in parts beginners judge to be irrelevant and don’t share.
I can highly recommend this free self-paced Docker training: Introduction to Containers
That is some great insight. I have been reading the documentation. I understand what you’re saying. Let me dig deeper into the documentation. Then I will be better prepared to ask questions in the proper format. I am just another developer learning how to make apps that are portable.
I’m so happy seeing this problem since I’m also experiencing the same thing. For context, my app is only a repository with Robot framework that I want to run in Docker so what I want to achieve here is I dockerize my entire project. I want to run it myself through executing the container.
In Docker Desktop, we can run an image through a Run feature/button in the Images menu which wraps
docker run <image> <env> etc command. I’ve always used this feature and it runs well as I expected. But just today I update the Docker Desktop and this is where the problem starts. In the new app when I hit the button the container was created but the container immediately exits with exit code 0. It confused me at first since my old container, which I created using the old version of Docker Desktop, runs perfectly fine—it doesn’t exit immediately.
I figured hours later by copying the
run command for my “broken” container and running it through the terminal. I tested it multiple times and it worked by adding the
-t flag. I conclude that the Docker Desktop doesn’t send
-t flag when running the container. I looked up the setting to change this. However, I can’t find anything up until now.
Not sure if it’s a bug or if is there something I could do to it. Hopefully, it brings more clarity to the issue.
This is the command I copied from Docker Desktop.
docker run --hostname=24cec45ec97e --env=PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --env=LANG=C.UTF-8 --env=GPG_KEY=E3FF2839C048B25C084DEBE9B26995E31025068 --env=PYTHON_VERSION=3.8.17 --env=PYTHON_PIP_VERSION=23.0.1 --env=PYTHON_SETUPTOOLS_VERSION=57.5.0 --env=PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/0d8570dc44796f4369b652222cf176b3db6ac70/public/get-pip.py --workdir=/app --runtime=runc -d automationv0.1.2:latest
Are you saying it used
-t before automatically when you ran a container from the GUI? Since I always start containers fom terminal, I don’t know if it’s true, but I think Docker Desktop should never have done that.
If it did, maybe it was a bugfix. If you want to keep a container alive and running, you need to run the process inside in the foreground, not background. If you run a simple bash container for the terminal, that’s one reason to have
-t, because the bash process wouldn’t be able to run without a pseudo terminal. But then why would someone run a termimnal in a container if they don’t want to use terminal to start a container?
Maybe if you want to use it for development and connect to it from visual studio code, but that is what the Dev Environment is for in Docker Desktop.