Docker Community Forums

Share and learn in the Docker community.

Container stops immediately after start


(Enero99) #1

Hello,
"/usr/bin/tor" start “tor” and finished at once.
The container is then also terminated.
And the “tor” service in the container is then terminated immediately.
“tor” unfortunately has not an option to run it in the foreground.

What can I do to run the container with “tor” without terminated immediately?

Excuse my English. English is a foreign language for me.
Greetings and thanks in advance
enero99

~$ cat docker-tor/Dockerfile
FROM debian:latest
MAINTAINER xyz <xyz@arcor.de>
ENV DEBIAN_FRONTEND noninteractive
RUN echo "deb http://deb.torproject.org/torproject.org jessie main" >/etc/apt/sources.list.d/tor.list && \
  echo "deb-src http://deb.torproject.org/torproject.org jessie main" >>/etc/apt/sources.list.d/tor.list
RUN apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 74A941BA219EC810 && \
  apt-get update && \
  apt-get install tor deb.torproject.org-keyring obfsproxy -y
COPY ./torrc /etc/tor/
EXPOSE 9001
EXPOSE 49656
EXPOSE 48179
CMD [ "/usr/bin/tor" ]

~$ docker build --rm -t debian/tor docker-tor/
~$ docker images
REPOSITORY TAG    IMAGE ID     CREATED       VIRTUAL SIZE
debian/tor latest 5c5dfd187f4e 5 seconds ago 259.6 MB
debian     latest df2a0347c9d0 12 days ago   125.2 MB

~$ docker run -p 9001:9001/tcp -p 48179:48179/tcp -p 49656:49656/tcp -d --name tor debian/tor:latest
54dfccfcac294e51001f455a43266483823d6170680c415b3e3f52c4e1fd622c

~$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
54dfccfcac29        debian/tor:latest   "/usr/bin/tor"      46 seconds ago      Exited (0) 44 seconds ago                       tor