WSL,Docker:有时无法在装入的卷中访问文件

时间:2018-07-18 08:14:19

标签: docker docker-compose windows-subsystem-for-linux

我正在使用Docker for Windows(WSL),并且已成功安装卷并且可以访问大多数文件。

但是,有时我会遇到奇怪的行为,并且某些文件始终无法读取,正如您在Docker容器中的简单ls + cat示例中所看到的那样:

username@docker-container:/var/www/my-project/var/log$ ls -la                                                                
total 430                                                                                                                       
drwxr-xr-x 2 root root      0 Jul 18 07:34 .                                                                                    
drwxr-xr-x 2 root root      0 Jul 11 14:25 ..                                                                                   
-rwxr-xr-x 1 root root      0 Jul 18 07:35 .gitkeep                                                                             
-rwxr-xr-x 1 root root  40815 Jul 18 07:30 access.log                                                                           
-rwxr-xr-x 1 root root 396308 Jul 18 07:37 dev.log                                                                              
-rwxr-xr-x 1 root root    340 Jul 17 16:08 error.log                                                                                 
username@docker-container:/var/www/my-project/var/log$ cat dev.log                                                           
cat: dev.log: No such file or directory                                                                                         
username@docker-container:/var/www/my-project/var/log$ cat dev.log                                                           
cat: dev.log: No such file or directory                                    
username@docker-container:/var/www/my-project/var/log$ cat dev.log                                                           
[2018-07-18 09:34:10] doctrine.DEBUG: SELECT t0.store AS ... (ETC)

(… This time it was possible to be read! …)


(... Then I try again and I can't open it, even though the file is still there ...)

username@docker-container:/var/www/my-project/var/log$ cat dev.log                                                           
cat: dev.log: No such file or directory          

username@docker-container:/var/www/my-project/var/log$ ls -la                                                                
total 434                                                                                                                       
drwxr-xr-x 2 root root      0 Jul 18 07:34 .                                                                                    
drwxr-xr-x 2 root root      0 Jul 11 14:25 ..                                                                                   
-rwxr-xr-x 1 root root      0 Jul 18 07:35 .gitkeep                                                                             
-rwxr-xr-x 1 root root  40815 Jul 18 07:30 access.log                                                                           
-rwxr-xr-x 1 root root 398678 Jul 18 07:37 dev.log                                                                              
-rwxr-xr-x 1 root root    340 Jul 17 16:08 error.log   

如您所见,文件dev.log有时“不存在”。而且我不知道如何解决。

这是我的docker-compose.yml文件:

version: '3'
services:

  server:
    build: docker/server
    container_name: docker-container
    volumes:
      - /d/shared/my-project:/var/www/my-project

0 个答案:

没有答案