Sample Header Ad - 728x90

Inside Docker: mkdir(-p): No such file or directory

0 votes
0 answers
1438 views
I have encountered a strange problem where the mkdir -p command fails to create a directory and returns the following error message:
[root@202 ~]# pwd
/root
[root@202 ~]# mkdir -p a/b/c
mkdir: cannot create directory ‘a’: No such file or directory
However, if I execute the same command in the root directory, it works fine:
[root@202 /]# pwd
/
[root@202 /]# mkdir -p a/b/c
[root@202 /]# ls -lhrt a/b
total 0
drwxr-xr-x 2 root root 6 Mar 13 15:06 c
I am currently logged in as the root user, so I don't think it's a simple permission issue. Do you have any other ideas for troubleshooting? The permissions of the /root directory are as follows:
[root@202 ~]# ls -lhart /
dr-xr-x---    2 root root  114 Apr  1  2016 root
And when I tried to modify the permissions of the /root directory, I encountered the same strange phenomenon:
[root@202 ~]# chmod a+w ~
chmod: changing permissions of ‘/root’: No such file or directory
I am currently working within a Docker container and the system is CentOS 7. Docker version: 6e3bb8e/1.13.1 (released on 2017-02-08). Thanks in advance. --- The df of / and /root:
[root@202 /]# df -lh /root
Filesystem      Size  Used Avail Use% Mounted on
overlay         128G   14G  115G  11% /
If I try to create the /root directory (given the "No such file or directory" message earlier):
[root@202 /]# mkdir /root
mkdir: cannot create directory ‘/root’: File exists
Asked by Mer (9 rep)
Mar 13, 2023, 08:10 AM
Last activity: Mar 13, 2023, 01:01 PM