0

I have a docker volume called hadoop_conf created at the default location /var/lib/docker/volumes/hadoop_conf/_data/. I need to copy some files from the host machine to this directory so the container can read them. My user has permission to run docker command but it does not have sudo access and copying into that directory requires sudo access. Is there any alternative to copy some files to this directory? any docker command?

HHH
  • 6,085
  • 20
  • 92
  • 164
  • Does this answer your question? [What is the right way to add data to an existing named volume in Docker?](https://stackoverflow.com/questions/37468788/what-is-the-right-way-to-add-data-to-an-existing-named-volume-in-docker) – leopal Dec 06 '19 at 15:23
  • In general you should use `docker run -v` with a host path, not a named volume, to inject config files into a container. You can't (shouldn't) directly edit the contents of a named volume. – David Maze Dec 06 '19 at 19:01

1 Answers1

1

You can use docker cp to copy files from your host to a container with hadoop_conf already mounted. You do not need sudo privileges for this.

https://docs.docker.com/engine/reference/commandline/cp/

docker cp myfile.txt mycontainer:/path/to/hadoop_conf_volume/
leeman24
  • 2,729
  • 3
  • 29
  • 42