<p>I want to collect docker container logs, By default, log files will be deleted when removing container. It cause several logs lost each time i update my service. How to keep log files after removing containers?
Or, Is there another way to collect all logs from containers without losing？</p>

<p>There will be two situations:</p>
<ul>
<li>If your logs are the stdout or stderr, you can save them before removing the container:</li>
</ul>
<pre class="lang-sh prettyprint-override"><code>docker logs CONTAINER_ID &gt; container.log
</code></pre>
<ul>
<li>If your logs are stored in some files, in this case, you can copy them out or mount a directory for them while running the container:</li>
</ul>
<pre class="lang-sh prettyprint-override"><code># Copy the logs out to the host
docker copy CONTAINER_ID:/path/to/your/log_file /host/path/to/store

# Mount a directory for them
docker run -d \
-v /host/path/to/store/logs:/container/path/stored/logs \
your-image
</code></pre>
