admin管理员组文章数量:1123557
I am using docker container to build my application and the ownership of the files and folders are non-root users..
I need to copy files from my physical local machine to the docker container and the ownership of files are root. here is the command I used to copy files from local to the docker container
docker cp resources <container-id>:/var/lib
The ownership of the resources folder I copied from local machine to the docker container is root, how can I change it to non-root ownership? The docker container don't have rights to perform chown command.
Is it possible to use "docker cp" command with ownership?
My docker container do have dockerfile and the dockerfile doesn't have anything regards to this. I just want to use non-root ownership of the files I copied from localhost to the docker container.
I am using docker container to build my application and the ownership of the files and folders are non-root users..
I need to copy files from my physical local machine to the docker container and the ownership of files are root. here is the command I used to copy files from local to the docker container
docker cp resources <container-id>:/var/lib
The ownership of the resources folder I copied from local machine to the docker container is root, how can I change it to non-root ownership? The docker container don't have rights to perform chown command.
Is it possible to use "docker cp" command with ownership?
My docker container do have dockerfile and the dockerfile doesn't have anything regards to this. I just want to use non-root ownership of the files I copied from localhost to the docker container.
Share Improve this question edited 20 hours ago xxestter asked 20 hours ago xxestterxxestter 4998 silver badges24 bronze badges 11- Please edit your question and add details of your docker configuration and how exactly you copy the files and how exactly you tried to fix the problem. Copy & paste the code instead of describing it. – Bodo Commented 20 hours ago
- @Bodo I have edited my issue, hopefully it will helps. thank yoou very much – xxestter Commented 20 hours ago
- It is still not clear why you need to copy the files and why you need the files to have a non-root ownership. Add more details what you want to achieve. There might be a different way. – Bodo Commented 20 hours ago
- 1 Is there a reason you cannot use mounted volumes for this? – Botje Commented 20 hours ago
- Looks like an XY problem – Bodo Commented 20 hours ago
1 Answer
Reset to default 0You can use the standard approach of piping tar
:
tar c resources | docker exec -i $container_name tar x -C /var/lib --uid $uid --gid $gid
where $uid
and $gid
are the non-root user and group ids used inside the container.
本文标签: linuxchown when docker cp from localhost to containerStack Overflow
版权声明:本文标题:linux - chown when docker cp from localhost to container - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736579015a1944918.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论