Sharing data between Docker containers can be achieved in multiple ways:
1. Data Volumes: These are the simplest form of persistence in Docker. After a volume has been created, you can use it in multiple containers. When a container is deleted, the volume remains in existence with its data.
Here’s an example of creating a volume:
```
docker volume create my_volume
```
And then using it in a container:
```
docker run -d —name my_container -v my_volume:/container_path my_image
```
1. Volume Containers: An earlier approach to sharing data between containers is to create a volume in one container and then use the —volumes-from parameter to include it in other containers. Here’s an example:
```
docker run —name=container_one -v /data busybox
docker run —name=container_two —volumes-from container_one busybox
```
In this case, container_two has access to all the volumes defined in container_one.
1. Shared File Systems: Docker supports different types of data storage drivers which can be used for sharing data between containers. For example, by mounting a host directory into the container as a bind mount.
Here’s an example using a bind mount:
```
docker run -d —name my_container -v /host/path:/container/path my_image
```
In this case, the data located at /host/path on your host OS will be presented at /container/path inside the Docker container.
However, these volumes are managed outside of Docker and can present security risks if not properly managed.
Note: Docker volumes are the preferred way to handle data persistence with Docker and are managed directly by Docker.