创建了卷的Docker容器后,本地主机上的权限更改为1000 [英] Permission changed to 1000 on local host after Docker container with volume created

查看:580
本文介绍了创建了卷的Docker容器后,本地主机上的权限更改为1000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用外部卷创建容器后,权限将变为1000。



drwxr-x --- 7 1000 1000 4096 Mar 02 01:13 my_domain



每次我都需要更改其用户名。 AS docker由root用户安装。
我如何避免这种情况?
任何人都可以写点东西吗?

解决方案

不要将其更改为其他 UID 。启动容器时,其权限可能会被容器本身更改。在这种情况下,您可能需要查看正在使用的Docker映像。



所以让我们来 mysql-docker 。启动它时,权限将会更改甚至对于已装入的卷也可以正常工作,否则您将面临权限问题,因为 mysql 用户无法写入任何数据。



基于您问题中的 weblogic12c 标记,我在 weblogic的Dockerfile

 运行chown oracle:oracle -R / u01 

如果您的数据保存在同一目录内的容器内,则 1000 可能表示容器内 oracle 用户,您还可以在容器内检查 / etc / passwd



因此 UID GID 在您的情况下为 1000 表示容器进程正在使用的容器内的用户,因为您没有用户与此匹配 UID 会以数字形式显示。如果需要,可以在主机上创建具有相同UID的用户。因此,要为 1000 提供用户名和组名,您需要执行以下操作:

  useradd -U -u 1000 oracle 

上述命令将创建一个名为 oracle 和一个由于使用 -U 而UID / GID相同的名称的组将是 1000 由于使用 -u

  -u,--uid新帐户
的UID用户ID -U,--user-group创建与用户


接下来,如果在主机上执行以下命令,则会得到一个结果,告诉您用户组和uid / gid:

  id oracle 
uid = 1000(oracle)gid = 1000(oracle)groups = 1000(oracle)


After my container is created with external volume, Permission becomes 1000.

drwxr-x--- 7 1000 1000 4096 Mar 02 01:13 my_domain

Everytime i need to changed it my user. AS docker is installed by root user. How can i avoid this situation ? Can anyone please write something ?

解决方案

Don't change it to a user with different UID. The permission might be changed by the container itself when you start it. you may need to review the docker image that you are using in this case.

So let's take mysql-docker for example. when you start it, the permissions will be changed even for the mounted volume in order to work properly otherwise you will face permissions issue because the mysql user is not able to write any data.

Based on weblogic12c tag in your question, I have noticed the following in the Dockerfile of weblogic:

RUN  chown oracle:oracle -R /u01

If your data is saved inside the container within the same directory then probably that 1000 represents oracle user inside the container, you can check /etc/passwd inside the container also.

So the UID and GID which is 1000 in your case represents a user inside the container that is being used by the container process and because you don't have a user matches this UID it will appear in a numerical way as you see it. You may create a user with the same UID on the host if you want to. So in order to give 1000 a username and group name you need to do the following:

useradd -U -u 1000 oracle

The above command will create a user called oracle and and a group with same name due to using -U and the UID/GID will be 1000 due to using -u

  -u, --uid UID                 user ID of the new account
  -U, --user-group              create a group with the same name as the user

Next if you executed the following command on the host you will get a result tells you the user group and the uid/gid:

id oracle
uid=1000(oracle) gid=1000(oracle) groups=1000(oracle)

这篇关于创建了卷的Docker容器后,本地主机上的权限更改为1000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆