VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-share-data-between-the-docker-container-and-the-host

⇱ How To Share Data Between the Docker Container and the Host | DigitalOcean


How To Share Data Between the Docker Container and the Host

Updated on September 30, 2021
πŸ‘ How To Share Data Between the Docker Container and the Host

Introduction

In general, Docker containers are ephemeral, running just as long as it takes for the command issued in the container to complete. By default, any data created inside the container is only available from within the container and only while the container is running.

Docker volumes can be used to share files between a host system and the Docker container. For example, let’s say you wanted to use the official Docker Nginx image and keep a permanent copy of Nginx’s log files to analyze later. By default, the nginx Docker image will log to the /var/log/nginx directory inside the Docker Nginx container. Normally it’s not reachable from the host filesystem.

In this tutorial, we’ll explore how to make data from inside the container accessible on the host machine.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

Still looking for an answer?

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Excellent posts on Docker, Melissa. The way you break each command down in detail and explain the flags you use makes it easy to understand and learn.

It doesn’t work if the host is on the digitalocean and the local directory is on my laptop.

If I ran the container without -v do I need to recreate the container after if I want to add the share?

Excellent Post. Good post if we have any doubt about how docker is running internally. Keep it up.

Regards Vipul

Quick question tutorials. Do you have videos as well. sometimes, its faster to understand. I love digital ocean tutorials. Very well written with nice fonts, great content.

πŸ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

The developer cloud

Scale up as you grow β€” whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Β© 2026 DigitalOcean, LLC.Sitemap.