You can create a directory named logs in your current user’s home directory and bind-mount it to /var/log/nginx in the Nginx container using the following command: Prerequisitesįor this tutorial, you will need the following prerequisites: In this tutorial, you will learn how to share data between the inside of the Docker container and the host machine. For example, if you have an Nginx web server and you want to store the logs for audits, you can use a Docker volume to store the logs from the container in your host machine.
The data that is available inside the container can only be accessed from within the container during the runtime.ĭocker volumes can be used for accessing the files easily and storing them for a longer period. Generally, Docker containers only run for a certain period of time – the time it takes to run the command.