How to mount a directory in a Docker container to the host?
<p>Assume that i have an application with this simple Dockerfile:</p>

<pre><code>//...
RUN configure.sh --logmyfiles /var/lib/myapp
ENTRYPOINT ["starter.sh"]
CMD ["run"]
EXPOSE 8080
VOLUME ["/var/lib/myapp"]
</code></pre>

<p>And I run a container from that:</p>

<pre><code>sudo docker run -d --name myapp -p 8080:8080 myapp:latest
</code></pre>

<p>So it works properly and stores some logs in <code>/var/lib/myapp</code> of docker container.</p>

<p><strong>My question</strong> </p>

<p>I need these log files to automatically saved in host too, So how can i mount the <code>/var/lib/myapp</code> from the container to the  <code>/var/lib/myapp</code> in host server (without removing current container) ?</p>

<p><strong>Edit</strong></p>

<p>I also see <a href="https://stackoverflow.com/questions/31726407/docker-mount-directory-from-container-to-host">Docker - Mount Directory From Container to Host</a>, but it doesn't solve my problem i need a way to backup my files from docker to host.</p>