docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
34.11k stars 5.25k forks source link

Compose isn't sending the right paths to my VM #3259

Closed atrauzzi closed 8 years ago

atrauzzi commented 8 years ago

I have a boot2docker VM that's been created by docker-machine and I am running docker-compose 1.6.2, build 4d72027 on Windows, installed via pip.

All my containers that don't use bind mounts seem to be working, but as soon as I try to perform a relative bind mount, I end up getting this message:

ERROR: Cannot start container 713aaf8e67350f1182a8397b7ab68537f1ed9722d20f662a928d353c62c3f320: [9] System error: not a directory

This issue seems to have been lingering for quite some while since I first reported it late last year: https://github.com/docker/compose/issues/2301

If you'd like a sample of the project I'm using, head here: http://github.com/atruazzi/laravel-drydock

A simple docker-compose up in the root directory on Windows should yield the same issue as what I'm experiencing. My hunch is that the paths being sent to the docker daemon/engine aren't lining up with what is in the filesystem of the VM. Unfortunately, I have no way of debugging any of this as --verbose doesn't show the paths being sent.

dnephin commented 8 years ago

https://github.com/docker/compose/issues/2301#issuecomment-205315559

Please include the output of docker inspect <container id> to help debug please

atrauzzi commented 8 years ago

@dnephin - Don't worry about redacting any of the environment variables, it's just a dev environment:

[
    {
        "Id": "713aaf8e67350f1182a8397b7ab68537f1ed9722d20f662a928d353c62c3f320",
        "Created": "2016-04-03T19:58:40.797928319Z",
        "Path": "/usr/sbin/php5-fpm",
        "Args": [
            "-F",
            "-R"
        ],
        "State": {
            "Status": "created",
            "Running": false,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 0,
            "ExitCode": -1,
            "Error": "cantstart: Cannot start container 713aaf8e67350f1182a8397b7ab68537f1ed9722d20f662a928d353c62c3f320
: [9] System error: not a directory",
            "StartedAt": "0001-01-01T00:00:00Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:bf8284ddfdac0a297be91807ab7fb314923757928b2defa708187e5bf3748086",
        "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/713aaf8e67350f1182a8397b7ab68537f1ed9722d20f662a928d353c6
2c3f320/resolv.conf",
        "HostnamePath": "/mnt/sda1/var/lib/docker/containers/713aaf8e67350f1182a8397b7ab68537f1ed9722d20f662a928d353c62c
3f320/hostname",
        "HostsPath": "/mnt/sda1/var/lib/docker/containers/713aaf8e67350f1182a8397b7ab68537f1ed9722d20f662a928d353c62c3f3
20/hosts",
        "LogPath": "/mnt/sda1/var/lib/docker/containers/713aaf8e67350f1182a8397b7ab68537f1ed9722d20f662a928d353c62c3f320
/713aaf8e67350f1182a8397b7ab68537f1ed9722d20f662a928d353c62c3f320-json.log",
        "Name": "/drydock-webapp",
        "RestartCount": 0,
        "Driver": "aufs",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/c/Users/atrau/Development/laravel-drydock/resources/crontab:/etc/cron.d/laravel:rw",
                "/c/Users/atrau/Development/laravel-drydock/resources/php-fpm.conf:/etc/php5/fpm/php-fpm.conf:rw",
                "/c/Users/atrau/Development/laravel-drydock/laravel:/var/www:rw",
                "/c/Users/atrau/Development/laravel-drydock/resources/php-fpm.www.conf:/etc/php5/fpm/pool.d/www.conf:rw"

            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Links": [
                "/drydock-email:/drydock-webapp/maildev",
                "/drydock-queue:/drydock-webapp/drydock-queue",
                "/drydock-queue:/drydock-webapp/rabbitmq",
                "/drydock-cache:/drydock-webapp/drydock-cache",
                "/drydock-cache:/drydock-webapp/redis",
                "/drydock-database:/drydock-webapp/drydock-database",
                "/drydock-database:/drydock-webapp/postgres",
                "/drydock-email:/drydock-webapp/drydock-email"
            ],
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "ShmSize": 67108864,
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "KernelMemory": 0,
            "Memory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": -1,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null
        },
        "GraphDriver": {
            "Name": "aufs",
            "Data": null
        },
        "Mounts": [
            {
                "Source": "/c/Users/atrau/Development/laravel-drydock/laravel",
                "Destination": "/var/www",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Source": "/c/Users/atrau/Development/laravel-drydock/resources/php-fpm.www.conf",
                "Destination": "/etc/php5/fpm/pool.d/www.conf",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Source": "/c/Users/atrau/Development/laravel-drydock/resources/crontab",
                "Destination": "/etc/cron.d/laravel",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Source": "/c/Users/atrau/Development/laravel-drydock/resources/php-fpm.conf",
                "Destination": "/etc/php5/fpm/php-fpm.conf",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "713aaf8e6735",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "9000/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "DB_CONNECTION=pgsql",
                "CACHE_DRIVER=redis",
                "RABBITMQ_HOST=rabbitmq",
                "RABBITMQ_VHOST=/drydock",
                "MAIL_DRIVER=smtp",
                "RABBITMQ_LOGIN=drydock",
                "SESSION_DRIVER=redis",
                "APP_ENV=local",
                "APP_DEBUG=true",
                "REDIS_PORT=6379",
                "CACHE_PREFIX=laravel-drydock",
                "REDIS_HOST=redis",
                "DB_DATABASE=drydock",
                "QUEUE_DRIVER=rabbitmq",
                "RABBITMQ_QUEUE=laravel",
                "DB_USERNAME=drydock",
                "MAIL_HOST=maildev",
                "MAIL_PORT=25",
                "DB_HOST=postgres",
                "RABBITMQ_PASSWORD=drydock",
                "RABBITMQ_PORT=5672",
                "DB_PASSWORD=",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "-F",
                "-R"
            ],
            "Image": "atrauzzi/laravel-drydock",
            "Volumes": {
                "/etc/cron.d/laravel": {},
                "/etc/php5/fpm/php-fpm.conf": {},
                "/etc/php5/fpm/pool.d/www.conf": {},
                "/var/www": {}
            },
            "WorkingDir": "/var/www",
            "Entrypoint": [
                "/usr/sbin/php5-fpm"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "bf692acf7fb03078a91b07178603d335d82c53a7f65e2ec77c1feb78818baef7",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "laraveldrydock",
                "com.docker.compose.service": "webapp",
                "com.docker.compose.version": "1.6.2"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "8d897822e1921d7b34098358829128c667688744bbd01787e8b1a42059cd177a",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": null,
            "SandboxKey": "/var/run/docker/netns/8d897822e192",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "3c6cecfeb2229c74ea0ec964f5b72575275bfa08732a678b50fa8fee53e07471",
                    "EndpointID": "",
                    "Gateway": "",
                    "IPAddress": "",
                    "IPPrefixLen": 0,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": ""
                }
            }
        }
    }
]

Something interesting when I went to the path indicated for the bind mounts:

docker@default:~$ cd /c/Users/atrau/Development/laravel-drydock/resources
docker@default:/c/Users/atrau/Development/laravel-drydock/resources$ ls -Al
total 0
drwxr-xr-x    2 root     root            40 Apr  3 19:58 crontab/
drwxr-xr-x    2 root     root            40 Apr  3 19:58 php-fpm.conf/
drwxr-xr-x    2 root     root            40 Apr  3 19:58 php-fpm.www.conf/
docker@default:/c/Users/atrau/Development/laravel-drydock/resources$ cat php-fpm
.conf
cat: read error: Is a directory
docker@default:/c/Users/atrau/Development/laravel-drydock/resources$

The paths exist, but some of the ones that should be files are reporting to be directories?! Also, the filesystem appears to be mounted as root with read permissions for group and all, but this VM was made by docker-machine...

dnephin commented 8 years ago

If the path doesn't exist on the host (in this case the VM) then the path is created as a directory. If these are directories it could mean that it wasn't able to find the path.

It sounds like there might have been an issue with the virtualbox shared folders. Maybe try verifying they are setup properly for this path, and recreating the docker-machine ?

atrauzzi commented 8 years ago

I've tried recreating a few times now. I'm using the hyper-v driver for docker-machine, not VirtualBox.

Some of these paths are supposed to be files *.conf, and other obvious candidates.

dnephin commented 8 years ago

Oh, if you aren't using virtualbox then there probably aren't any file shares being created. I don't see anything about it in https://docs.docker.com/machine/drivers/hyper-v/

Do you see other host files in /c/Users/atrau ? Or only the files that you've defined as host volumes? If it's only the host volumes then you are missing a file share with the host. I believe you have to set that up yourself, it's only done for you by the virtualbox driver (I think).

atrauzzi commented 8 years ago

Alright! That definitely seemed to be the case.

I configured a cifs mount to my host and it's all working now. Just made sure to emulate the /c/Users convention.

Running into https://github.com/docker/compose/issues/3096 and https://github.com/docker/compose/issues/3194 now.