Docker Community Forums

Share and learn in the Docker community.

Container does not keep running

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

See the image below:

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.