<p>I have actively been looking for info on the internet concerning this, but it seems to be a somewhat particular use case.  </p>

<p>I am trying to deploy a docker container running a legacy back-end in a Kubernetes/Openshift cluster. </p>

<p>The container is started using an entrypoint.sh script which will initialize dependencies that the back-end requires before booting. </p>

<p>I want the back-end as PID 1 - as to capture the back-end logs with docker/openshift. </p>

<p>To do this I have an exec command at the end of the entrypoint.sh script which launches my back-end and which thus replaces the entrypoint.sh process - which is assigned PID 1 by docker - with my back-end.</p>

<p><strong>The problem:</strong> </p>

<p>At the moment the exec is executed in the entrypoint.sh, docker stops capturing the logs, and I thus don't have any logs from my back-end process captured by docker when performing "docker logs $MY_CONTAINER_ID".</p>

<p>When entering the container, I do see that everything functions properly: </p>

<p>My back-end process is running as PID 1, and the process file descriptors 1/2 are correctly setup capturing STDOUT and STDERR of my back-end process.</p>

<p>Does anyone know if this is a missing configuration issue? Or is docker simply designed to work like this considering that I am replacing PID 1 with exec?</p>

<p>I can't see anything wrong in what you are describing. The stdout/stderr of process ID 1 should be captured, as will any sub process if they inherit stdout/stderr of the parent process (process ID 1).</p>

<p>Where you can have problems is if an application is set up to log to a normal file and doesn't use stdout/stderr. In these cases if they will only accept a file, use <code>/proc/1/fd/1</code> as the log file path. This will result in the log messages getting output through stdout of process ID 1.</p>

<p>Do note that if your application uses a logging framework that wants to do its own log file rotation on the path you give it, you will need to disable that, you want it to keep using the same file path and not try and rename or truncate it. </p>
