问题示例:
docker run -ti -v my_passwd:/etc/passwd -v my_shadow:/etc/shadow --rm centos
[root@681a5489f3b0 /]# useradd test # does not work !?
useradd: failure while writing changes to /etc/passwd
[root@681a5489f3b0 /]# ll /etc/passwd /etc/shadow # permission check
-rw-r--r-- 1 root root 157 Oct 8 10:17 /etc/passwd
-rw-r----- 1 root root 100 Oct 7 18:02 /etc/shadow
使用 passwd 时也会出现类似的问题:
[root@681a5489f3b0 /]# passwd test
Changing password for user test.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: Authentication token manipulation error
我曾尝试使用 ubuntu 映像,但出现了同样的问题。
我可以从容器内手动编辑 passwd 文件和影子文件。
我在以下两台机器上遇到了同样的问题:
主机操作系统:CentOS 7 - SELinux 禁用
Docker 版本:1.8.2,构建 0a8c2e3
主机操作系统:CoreOS 766.4.0
Docker 版本:1.7.1,构建 df2f73d-dirty
我还在 GitHub 上打开了问题:https ://github.com/docker/docker/issues/16857