Start tor and polipo when I launch my container

I wrote my first Dockerfile in order to test Docker with tor and polipo.
My Dockerfile looks like:

# Pull base image.
FROM ubuntu:latest

# Upgrade system
RUN apt-get update && apt-get dist-upgrade -y --no-install-recommends && apt-get autoremove -y && apt-get clean

# Install TOR
RUN apt-get install -y --no-install-recommends tor tor-geoipdb torsocks && apt-get autoremove -y && apt-get clean

RUN apt-get update && apt-get install -y polipo

# Default ORPort

# Default DirPort 

# Default SOCKS5 proxy port 

# Default ControlPort
# Default polipo Port

RUN echo 'socksParentProxy = "localhost:9050"'  >> /etc/polipo/config
RUN echo 'socksProxyType = socks5'  >> /etc/polipo/config
RUN echo 'diskCacheRoot = ""' >> /etc/polipo/config

RUN echo 'ORPort 9001' >> /etc/tor/torrc
RUN echo 'ExitPolicy reject *:*' >> /etc/tor/torrc

RUN mkdir scrapy
ADD scrapyTor scrapy

RUN chmod 775 ./

my contains 3 lines:

  • Cannot connect from MySQL Workbench to dockerized MySQL server
  • docker untagged images with tag (using docker-compose)
  • Limit number of processes started inside docker container
  • Jenkins With Nginx Reverse Proxy And Resolver
  • OSX boot2docker trouble connecting to docker daemon
  • `docker-machine scp` from local directory to machine
  • #!/bin/bash                                                              
    /etc/init.d/tor start &
    /etct/init.d/polipo start &

    But when I launch this command:

    docker run -i -t id_image /bin/bash

    And once inside in the container when I launch ps, I see nothing.
    How I can resolve this?

  • Reset Docker Machine to run Docker commands on my local machine
  • Build Meteor in Docker cannot pass proxy setting
  • Docker's `docker0` device dies repeatedly (`inet addr` disappears)
  • Testing a dockerized Ruby on Rails app with MySQL on CircleCI
  • Is it possible to assign a specific node to create container with docker swarm?
  • Docker daemon memory leak due to logs from long running process
  • One Solution collect form web for “Start tor and polipo when I launch my container”

    Your Dockerfile should have a command defined like:

    CMD ./

    Then you do not need to provide /bin/bash as a run command. Only the following should be enough:

    docker run -i -t id_image

    By the way: your script file creates two processes running in background. That will not work!

    Docker containers need to have always a process in foreground. In your case the container would stop immediately after executing your start script. And while stopping the SIGTERM will not properly be sent to those background processes so they will simply get killed and may leave some corrupt data.

    You should think about using supervisord instead when you need to have multiple processes in your container started.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.