title: Running a background process in container during one step in docker build
body: <p>I'd like to run integration tests of an app during <code>docker build</code>. These tests require a Redis server being available.</p>
  
  <p>How can I run <code>redis-server</code> and keep it running in the background during the integration-test step, i.e. <code>gradle build</code>?</p>
  
  <p>Here is the essence of my <code>Dockerfile</code>:</p>
  
  <pre><code>FROM ubuntu:16.04
  
  # apt-get install stuff
  # ...
  # install gradle
  # build and install redis
  
  WORKDIR /app
  ADD . /app
  
  # TODO: start redis-server
  
  # run unit tests / integration tests of app
  RUN /opt/gradle/gradle-4.6/bin/gradle build --info
  
  # TODO: stop redis-server
  
  # build app
  RUN ./gradlew assemble
  
  # start app with
  # docker run
  CMD ["java", "-jar", "my_app.jar"]
  </code></pre>