Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker container not starting (docker start)

Tags:

docker

I created the container with the following command:

docker run -d -p 52022:22 basickarl/docker-git-test 

Here are the commands:

root@basickarl:~# docker ps CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES root@basickarl:~# docker ps -a CONTAINER ID        IMAGE                              COMMAND             CREATED             STATUS                           PORTS               NAMES e4ac54468455        basickarl/docker-git-test:latest   "/bin/bash"         7 minutes ago       Exited (0) 26 seconds ago                            adoring_lumiere      22d7c5d83871        basickarl/docker-git-test:latest   "/bin/bash"         2 hours ago         Exited (127) About an hour ago                       thirsty_wright       root@basickarl:~# docker attach --sig-proxy=false e4 FATA[0000] You cannot attach to a stopped container, start it first  root@basickarl:~# docker start e4 e4 root@basickarl:~# docker attach --sig-proxy=false e4 FATA[0000] You cannot attach to a stopped container, start it first  root@basickarl:~#  

Not much to say really, I'm expecting the container to start and stay upp. Here are logs:

root@basickarl:~# docker logs e4 root@basickarl:~#  
like image 717
basickarl Avatar asked Apr 30 '15 01:04

basickarl


People also ask

Why is my docker not starting?

Go to performance and then CPU to verify whether Virtualization is enabled or not. If virtualization is disabled Docker Desktop cannot start. If the virtualization is disabled in your machine then you need to enable it from BIOS Settings.

How do I start a container in docker?

This is similar to docker run -d except the container is never started. You can then use the docker container start (or shorthand: docker start ) command to start the container at any point. This is useful when you want to set up a container configuration ahead of time so that it is ready to start when you need it.


1 Answers

You are trying to run bash, an interactive shell that requires a tty in order to operate. It doesn't really make sense to run this in "detached" mode with -d, but you can do this by adding -it to the command line, which ensures that the container has a valid tty associated with it and that stdin remains connected:

docker run -it -d -p 52022:22 basickarl/docker-git-test 

You would more commonly run some sort of long-lived non-interactive process (like sshd, or a web server, or a database server, or a process manager like systemd or supervisor) when starting detached containers.

If you are trying to run a service like sshd, you cannot simply run service ssh start. This will -- depending on the distribution you're running inside your container -- do one of two things:

  • It will try to contact a process manager like systemd or upstart to start the service. Because there is no service manager running, this will fail.

  • It will actually start sshd, but it will be started in the background. This means that (a) the service sshd start command exits, which means that (b) Docker considers your container to have failed, so it cleans everything up.

If you want to run just ssh in a container, consider an example like this.

If you want to run sshd and other processes inside the container, you will need to investigate some sort of process supervisor.

like image 162
larsks Avatar answered Sep 20 '22 20:09

larsks