Dotnet-docker: System.UnauthorizedAccessException: Access to the path '/proc/1/map_files' is denied.

Created on 17 Apr 2018  Â·  13Comments  Â·  Source: dotnet/dotnet-docker

Steps to reproduce the issue

start container by 'docker-compose'
with command 'dotnet /data/app/ChangeCore.dll'

Actual behavior

Can't start, exited with code 139.
Error Logs:

Unhandled Exception: System.UnauthorizedAccessException: Access to the path '/proc/1/map_files' is denied. ---> System.IO.IOException: Operation not permitted,
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher(),
   at System.IO.FileSystemWatcher.RunningInstance..ctor(FileSystemWatcher watcher, SafeFileHandle inotifyHandle, String directoryPath, Boolean includeSubdirectories, NotifyFilters notifyFilters, CancellationToken cancellationToken),
   at System.IO.FileSystemWatcher.RunningInstance.AddDirectoryWatchUnlocked(WatchedDirectory parent, String directoryName),
   at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed(),
   at System.IO.FileSystemWatcher.StartRaisingEvents(),
   at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value),
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter),
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer),
   at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source),
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors),
   at ChangeCore.Program.Main(String[] args) in F:\ChangeCore\ChangeCore\Program.cs:line 17,
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build(),
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build(),
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder),
   at System.IO.Enumeration.FileSystemEnumerator`1.FindNextEntry(),
   at System.IO.Enumeration.FileSystemEnumerator`1.MoveNext(),
   --- End of inner exception stack trace ---

Additional information (e.g. issue happens only occasionally)

Container info

{
    "AppArmorProfile": "",
    "Args": [
        "/data/app/ChangeCore.dll"
    ],
    "Config": {
        "AttachStderr": false,
        "AttachStdin": false,
        "AttachStdout": false,
        "Cmd": [
            "dotnet",
            "/data/app/ChangeCore.dll"
        ],
        "Domainname": "",
        "Entrypoint": null,
        "Env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "ASPNETCORE_URLS=http://+:80",
            "DOTNET_RUNNING_IN_CONTAINER=true",
            "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true",
            "DOTNET_VERSION=2.1.0-preview2-26406-04"
        ],
        "Hostname": "63917d79f47b",
        "Image": "microsoft/dotnet:2.1-runtime-alpine",
        "Labels": {
            "com.docker.compose.config-hash": "2ca6d8596e3e730096b48286f48289cc83650cb29d1f6746677cf351f909c80e",
            "com.docker.compose.container-number": "1",
            "com.docker.compose.oneoff": "False",
            "com.docker.compose.project": "manage-docker",
            "com.docker.compose.service": "netcore-manage",
            "com.docker.compose.version": "1.21.0"
        },
        "OnBuild": null,
        "OpenStdin": false,
        "StdinOnce": false,
        "Tty": false,
        "User": "",
        "Volumes": {
            "/data/app": {},
            "/data/app/Logs": {}
        },
        "WorkingDir": ""
    },
    "Created": "2018-04-17T07:40:29.436425387Z",
    "Driver": "overlay2",
    "ExecIDs": null,
    "GraphDriver": {
        "Data": {
            "LowerDir": "/var/lib/docker/overlay2/9544e4950fe87472e156cb583c0646fbd5f1c24274e37acfb20846ea0d113ac3-init/diff:/var/lib/docker/overlay2/311becfd97576badb1a16e52bbf2604075ca16554c631da065bc96d2c981b6ba/diff:/var/lib/docker/overlay2/d71f9302db4d9e7e0c6db68e988d31136695b4cde6444f7d523d1bc60235481a/diff:/var/lib/docker/overlay2/bbd97e92267dba862976e4f8bd9a533c3fa6cf80a0ad562b9a1250b45c5df781/diff",
            "MergedDir": "/var/lib/docker/overlay2/9544e4950fe87472e156cb583c0646fbd5f1c24274e37acfb20846ea0d113ac3/merged",
            "UpperDir": "/var/lib/docker/overlay2/9544e4950fe87472e156cb583c0646fbd5f1c24274e37acfb20846ea0d113ac3/diff",
            "WorkDir": "/var/lib/docker/overlay2/9544e4950fe87472e156cb583c0646fbd5f1c24274e37acfb20846ea0d113ac3/work"
        },
        "Name": "overlay2"
    },
    "HostConfig": {
        "AutoRemove": false,
        "Binds": [
            "/home/project/manage-docker/logs/netcore:/data/app/Logs:rw",
            "/home/project/manage-docker/app/netcore-manage:/data/app:rw"
        ],
        "BlkioDeviceReadBps": null,
        "BlkioDeviceReadIOps": null,
        "BlkioDeviceWriteBps": null,
        "BlkioDeviceWriteIOps": null,
        "BlkioWeight": 0,
        "BlkioWeightDevice": null,
        "CapAdd": null,
        "CapDrop": null,
        "Cgroup": "",
        "CgroupParent": "",
        "ConsoleSize": [
            0,
            0
        ],
        "ContainerIDFile": "",
        "CpuCount": 0,
        "CpuPercent": 0,
        "CpuPeriod": 0,
        "CpuQuota": 0,
        "CpuRealtimePeriod": 0,
        "CpuRealtimeRuntime": 0,
        "CpuShares": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "DeviceCgroupRules": null,
        "Devices": null,
        "DiskQuota": 0,
        "Dns": null,
        "DnsOptions": null,
        "DnsSearch": null,
        "ExtraHosts": null,
        "GroupAdd": null,
        "IOMaximumBandwidth": 0,
        "IOMaximumIOps": 0,
        "IpcMode": "shareable",
        "Isolation": "",
        "KernelMemory": 0,
        "Links": null,
        "LogConfig": {
            "Config": {},
            "Type": "json-file"
        },
        "Memory": 0,
        "MemoryReservation": 0,
        "MemorySwap": 0,
        "MemorySwappiness": null,
        "NanoCpus": 0,
        "NetworkMode": "manage-docker_default",
        "OomKillDisable": false,
        "OomScoreAdj": 0,
        "PidMode": "",
        "PidsLimit": 0,
        "PortBindings": {},
        "Privileged": false,
        "PublishAllPorts": false,
        "ReadonlyRootfs": false,
        "RestartPolicy": {
            "MaximumRetryCount": 0,
            "Name": ""
        },
        "Runtime": "runc",
        "SecurityOpt": null,
        "ShmSize": 67108864,
        "UTSMode": "",
        "Ulimits": null,
        "UsernsMode": "",
        "VolumeDriver": "",
        "VolumesFrom": []
    },
    "HostnamePath": "/var/lib/docker/containers/63917d79f47bd5b9ca51fbb840e4faec0eb1cc00c25cec8b53e4f7eb7093204d/hostname",
    "HostsPath": "/var/lib/docker/containers/63917d79f47bd5b9ca51fbb840e4faec0eb1cc00c25cec8b53e4f7eb7093204d/hosts",
    "Id": "63917d79f47bd5b9ca51fbb840e4faec0eb1cc00c25cec8b53e4f7eb7093204d",
    "Image": "sha256:72d65a69822461780839438d4d96f85bde170afbf4dabae11d4fd5358157c63d",
    "LogPath": "/var/lib/docker/containers/63917d79f47bd5b9ca51fbb840e4faec0eb1cc00c25cec8b53e4f7eb7093204d/63917d79f47bd5b9ca51fbb840e4faec0eb1cc00c25cec8b53e4f7eb7093204d-json.log",
    "MountLabel": "",
    "Mounts": [
        {
            "Destination": "/data/app/Logs",
            "Mode": "rw",
            "Propagation": "rprivate",
            "RW": true,
            "Source": "/home/project/manage-docker/logs/netcore",
            "Type": "bind"
        },
        {
            "Destination": "/data/app",
            "Mode": "rw",
            "Propagation": "rprivate",
            "RW": true,
            "Source": "/home/project/manage-docker/app/netcore-manage",
            "Type": "bind"
        }
    ],
    "Name": "/netcore-manage",
    "NetworkSettings": {
        "Bridge": "",
        "EndpointID": "",
        "Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "HairpinMode": false,
        "IPAddress": "",
        "IPPrefixLen": 0,
        "IPv6Gateway": "",
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "MacAddress": "",
        "Networks": {
            "manage-docker_default": {
                "Aliases": [
                    "63917d79f47b",
                    "netcore-manage"
                ],
                "DriverOpts": null,
                "EndpointID": "",
                "Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "IPAMConfig": null,
                "IPAddress": "",
                "IPPrefixLen": 0,
                "IPv6Gateway": "",
                "Links": null,
                "MacAddress": "",
                "NetworkID": "ebd53d11cecae792d9b550fab743eabba3eea748014963cc05bfcad1021aa846"
            }
        },
        "Ports": {},
        "SandboxID": "a000e509bf186207ddb2a176df035d7cc1fea6cd6e1184f35da5635285f3fc59",
        "SandboxKey": "/var/run/docker/netns/a000e509bf18",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null
    },
    "Path": "dotnet",
    "Platform": "linux",
    "ProcessLabel": "",
    "ResolvConfPath": "/var/lib/docker/containers/63917d79f47bd5b9ca51fbb840e4faec0eb1cc00c25cec8b53e4f7eb7093204d/resolv.conf",
    "RestartCount": 0,
    "State": {
        "Dead": false,
        "Error": "",
        "ExitCode": 139,
        "FinishedAt": "2018-04-17T07:40:31.011594141Z",
        "OOMKilled": false,
        "Paused": false,
        "Pid": 0,
        "Restarting": false,
        "Running": false,
        "StartedAt": "2018-04-17T07:40:30.33403832Z",
        "Status": "exited"
    }
}

Output of docker version

Client:
 Version:   18.03.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built: Wed Mar 21 23:09:15 2018
 OS/Arch:   linux/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:  18.03.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   0520e24
  Built:    Wed Mar 21 23:13:03 2018
  OS/Arch:  linux/amd64
  Experimental: false

Output of docker info

Client:
 Version:   18.03.0-ce
 API version:   1.37
 Go version:    go1.9.4
 Git commit:    0520e24
 Built: Wed Mar 21 23:09:15 2018
 OS/Arch:   linux/amd64
 Experimental:  false
 Orchestrator:  swarm

Server:
 Engine:
  Version:  18.03.0-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.4
  Git commit:   0520e24
  Built:    Wed Mar 21 23:13:03 2018
  OS/Arch:  linux/amd64
  Experimental: false
[root@izm5e0jvoyzncfb3zicdgxz manage-docker]# docker info
Containers: 4
 Running: 2
 Paused: 0
 Stopped: 2
Images: 10
Server Version: 18.03.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-514.26.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 992.6MiB
Name: izm5e0jvoyzncfb3zicdgxz
ID: 7R6P:6YKZ:UQOJ:7OJZ:K7RF:W6BX:J6TO:ZXEM:EZM6:XBKG:5TCN:32RQ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Most helpful comment

Setting the working directory to the app directory in the compose file addresses the issue - working_dir: /app

All 13 comments

@SaekiRaku, can you please include the detailed steps necessary to reproduce this issue? Without seeing your Dockerfile, compose file and steps taken, it is difficult to provide help.

I extract my project's config, and build a example project with Visual Studio. And here it is: https://github.com/SaekiRaku/Issue-485-dotnet-docker

And it's running perfect on my Macbook(MacOS), and failed on my server which system is CentOS 7.2.

Thank you. @MichaelSimons

And I bought a temporary server that may help to discover the problem. The server will expire a week later.

IP : XXX
User : root
Password : XXXX

Project Path : /home/project

@SaekiRaku - I edited you previous comment and removed the IP and Password as I don't think you want everyone in the world having access to them 😃

@MichaelSimons Thanks😜, but it's ok, just a cheap single server. And it won't cost anything whatever anyone did on it. And this server's environment is mostly same as my production server.

@SaekiRaku - Can you send me the info to connect to you test machine? I was unable to reproduce the issue within my environment using your test project. You can send them to me - msimons at microsoft

@MichaelSimons 👌I've sent it by email.

Setting the working directory to the app directory in the compose file addresses the issue - working_dir: /app

Thank you very much. It's work perfect for me, thanks.😃

Why does the container work on Windows machine but not in a Linux environment?

If I do implement this change in the docker-compose.yml, I get following message:
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

What is wrong here?

@kwitkamp - It would be best if you could open an issue specific to your situation - I'm not making the connection on how it is related to this problem. Please include steps that can be used to reproduce the problem.

That being said, a common source of the error you mention within Linux is due to case sensitivity. Make sure your paths and assembly names are specified with the correct casing.

It is related to this problem, because I start with the same exception:
"Access to the path '/proc/1/map_files' is denied."

I create a docker image on a windows machine and from this image I can create and run a container on the same windows machine. When I create and run a container from the same image on a linux machine i get: "Access to the path '/proc/1/map_files' is denied."

I can also create the image directly on the linux machine, but with the same resulting exception when running in a container.

Adding the "working_dir" to the compose file doesn't help in my case.

@kwitkamp - Can you open a new issue and include steps that can be used to reproduce the issue?

I create a docker image on a windows machine and from this image I can create and run a container on the same windows machine. When I create and run a container from the same image on a linux machine i get: "Access to the path '/proc/1/map_files' is denied."

This is not enough detail for me to provide much help with. What microsoft/dotnet images are you using? Do you have a Dockerfile, if so what does it look like? What docker commands are you executing? What does your docker compose file look like?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dapalmi picture dapalmi  Â·  4Comments

wu-yafeng picture wu-yafeng  Â·  6Comments

TheYorkshireDev picture TheYorkshireDev  Â·  5Comments

MichaelSimons picture MichaelSimons  Â·  5Comments

williamdenton picture williamdenton  Â·  6Comments