How to get back to life docker container? - docker

My docker container hangs and don't have any idea how to get his back to life? I can't stop or restart it, there happens nothing. I can't even export him.

You could use service docker restart to restart the docker deamon (assuming you are using linux)

You can try these ideas :
Check the problem by looking the logs docker logs $container-name
You can try to create new image from your container with docker commit and create a new container.
You can create a new container from your initial image or your docker-compose.

Related

A windows container cannot be stopped succesfully

I use the dotnet3.5 image to run containers on win10 with docker desktop 2.1.0.1(37199). Sadly, I found that after I had created a container, did nothing to it, and left it alone for 4 days, the container automotically became unstoppable. The snapshot tells the story.
The container seemed existing there when docker ps -a, but I cannot get into the container by docker exec. And for I cannot stop it--the docker stop process hangs there after I use docker stop container2--I cannot rm the container.
The only way to resolve this issue is to restore docker desktop's factory setting.
By the way, although in the snapshot the running image is aspnet:3.5-windowsservercore-10.0.14393.953, this issue also happens when the aspnet:3.5
Does anyone have good ideas to the unstoppable container? Any suggestions are welcome.
The command used above is incorrect. There is a difference between the commands and options we use. "# docker ps" or "# docker container ls" will give you the list of currently running processes or active containers.
Whereas "-a" will give you all the list of all those which are used to date which contains the list of active and deleted containers.
In your case, the container was is not there and you are trying to access the one which is non-existing, which is why it is stuck.

How can I get a container (NOT an image) to restart on system startup

I want to be able to make changes in a container and if I were to restart my computer, the CONTAINER would restart so it wouldn't be a fresh image in a new container like docker run restart=always does.
Is there an easy way to do this through docker commands similar to the one mentioned above, or do I have to make a script that does a docker start command everytime my system starts?

Docker container goes to excited state when i use to start. Why?

I am very new to this docker things. I created containers in docker when i use to start my container it suddenly goes to excited state. I am trying to assign port:7050 to that container. All other container which i have created they use start but one orderer container when i use to turn it on, it automatically goes to excited state.
You can refer image :
Error: Container goes to excited state
Please guide me through this, i am not getting what is the problem. I tried removed all the docker conatiner and again created but i am getting same problem.
Thanks in adavnce.
Have you tried with
docker run -d ?
This will prevent the container from exiting.
If for example, you initialize a service and it runs in the background probably the container will understand that it finished its job and it will exit.
You can check this post for more information Docker container will automatically stop after "docker run -d"
First thing would be to check the logs of the pod as with:
docker logs $id
where you swap $id for the container id as you could see in the image you linked
If that doesn't tell you enough you can also call:
docker inspect $id

Why does my non-volume data in Docker container persist even after restarting the container?

In some places when I read about Docker containers, I found some people talking that they lose their data (saved inside the container and not a part of volume data) when they restart the container.
I tried to create a simple Ubuntu container like this: docker run -it ubuntu /bin/bash, and created some files inside the container and then restarted it, but my data still there. Why does that actually happen? why do my data still there? Is this something new in the newer versions of Docker or do I have misunderstanding for something?
The data is lost when the container is removed, not when it's stopped or restarted.
Basically, if you do docker ps, if the containers keeps the same id (the big ugly hexadecimal id), the data is not lost.
It gets complicated when somehow your docker containers are not managed by you, but by some kind of automated-managing method. Tools like these usually start new containers if there is failure. In that case you should mount a volume to store your data on the host.
You might want to look at the Container Lifecycle: https://github.com/wsargent/docker-cheat-sheet#lifecycle
docker create creates a container but does not start it.
docker rename allows the container to be renamed.
docker run creates and starts a container in one operation.
docker rm deletes a container.
docker update updates a container's resource limits.
If you do docker rm and docker run again your state will not be there anymore.
If you want a transient container, docker run --rm will remove the container after it stops.

How to have docker restart container with a completely new container?

It seems like the --restart option for docker run will try to restart the exact same container which has stopped. I would like it to restart with a completely new container, as if I had just run the 'docker run' command again. Is this currently possible?
Think of a docker "container" as an instance of a docker "image". Once you've created that instance it will live on with its state. If you want a new container you'll need to create a new one with the same image with "docker run".
If you have lots of parameters passed in when you create your container, you might want to checkout using docker-compose for the behavior you want. That way you can create a docker-compose.yml file with all the parameters you use to create your container then run:
docker-compose up --force-recreate
This would manage creating the exact container you want each time.

Resources