# Container does not keep running

**URL:** <https://forums.docker.com/t/container-does-not-keep-running/27309>\
**Category:** General\
**Tags:** docker\
**Created:** [January 19, 2017, 10:27am UTC](https://forums.docker.com/t/container-does-not-keep-running/27309 "2017-01-19T10:27:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vagkaefer](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/vagkaefer/32/14957_2.png) [@vagkaefer](https://forums.docker.com/u/vagkaefer)\
**Post date:** [January 19, 2017, 10:27am UTC](https://forums.docker.com/t/container-does-not-keep-running/27309/1 "2017-01-19T10:27:39Z")

</div>

Well, I’m having trouble keeping containers running. I create the container, it starts, but it is automatically terminated.

See the image below:

![](https://global.discourse-cdn.com/docker/original/2X/8/83e1d46554829f19785ed760812451139f8a6924.png)

The events:

```
[vagner@localhost ~]$ docker events
2017-01-19T08:40:36.256233911-02:00 network connect a4e91c43ed5f9ccab4bbd67668c49126610125287c97fd5cc8168f4ef5f82947 (container=fc7e8961fd0e53619cbc2f21ea2ae17fc3f0a684077df22499c56b194519922f, name=bridge, type=bridge)
2017-01-19T08:40:36.435065547-02:00 container start fc7e8961fd0e53619cbc2f21ea2ae17fc3f0a684077df22499c56b194519922f (image=sdi:client, name=client3)
2017-01-19T08:40:36.519174868-02:00 container die fc7e8961fd0e53619cbc2f21ea2ae17fc3f0a684077df22499c56b194519922f (exitCode=0, image=sdi:client, name=client3)
2017-01-19T08:40:36.675561905-02:00 network disconnect a4e91c43ed5f9ccab4bbd67668c49126610125287c97fd5cc8168f4ef5f82947 (container=fc7e8961fd0e53619cbc2f21ea2ae17fc3f0a684077df22499c56b194519922f, name=bridge, type=bridge)

```

The Dockerfile from the image “sdi:client”:

```
# sistema utilizado
FROM ubuntu:latest

# mantenedor
MAINTAINER Vagner Kaefer <vagner@kaefer.eng.br>

# instala o sshd e as ferramentas de rede
RUN apt-get update && apt-get install -y openssh-server net-tools iputils-ping

# cria o diretorio do sshd
RUN mkdir /var/run/sshd

# autoriza login como root
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

# descomenta a configuracao do arquivo com as chaves autorizadas 
RUN sed -i 's/#AuthorizedKeysFile/AuthorizedKeysFile/' /etc/ssh/sshd_config

# desabilita login por senha/text clear
#RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config

# altera a senha do root para sdi
RUN echo "root:sdi" | chpasswd

RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

# cria a pasta das chaves e copia a chave autorizada
RUN mkdir -p /root/.ssh
COPY chave.pub /root/.ssh/authorized_keys
RUN chmod 700 /root/.ssh
RUN chmod 600 /root/.ssh/authorized_keys

ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile

# abre a porta 22
EXPOSE 22 

# not work?
CMD ["/usr/sbin/sshd", "-D"]

#aqui inicia o servico do ssh quando o container é criado...
ENTRYPOINT service ssh restart & bash

```

I think I understood something wrong. And one more thing, the Dockerfile CMD command does not work in this example. Because when the container is started the SSH is disabled. So I put the ENTRYPOINT to start the service.

I need the containers to keep running. Because another container will send jobs to these clients. =/

Thank you very much.
