There are several cases:
- In the container, the
elasticsearch.yml file is located in the volume data directory
The volume data directory is a special backend for storing data for Docker containers called vfs backend. Directories are essentially normal directories displayed on the host file system, and therefore do not provide copy-write capabilities. Mostly mapped directories are located in /var/lib/dockers/vfs/dir/{container_id} , but this is configurable. Of course, you can use docker inspect {container_name} to check the location:
$> docker inspect my_container ..... (omitted output) "Volumes": { "/datadir": "/var/lib/docker/vfs/dir/b2479214c25cd39c901c3211ed14cb9668eef822a125ca85de81425d53c9ccee" },
As you can see, /datadir , which is the volume data directory in the container, maps to /var/lib/docker/vfs/dir/b2479214c25cd39c901c3211ed14cb9668eef822a125ca85de81425d53c9ccee of the host file system. In such circumstances, the answer to your question is quite simple: just copy them as regular files into the mapped host directory.
- The directory in the container is not a volume data directory.
Since Docker can use multiple storage backends for non-volumes, there is no simple answer to your question.
If you used AUFS as a backend, the container file system is mounted on the host file system, which is somewhat similar to the case of vfs. You can find the mapped directory in the host file system and access the files there. For more information about AUFS in Docker, see Docker and AUFS in practice .
If you use other servers, for example. devicemapper or btrfs, I think there is no easy way to access container files from the host. Perhaps you can try the @VonC method.
source share