faradayio / cage

Develop and deploy complex Docker applications
http://cage.faraday.io
Apache License 2.0
307 stars 26 forks source link

cage doesn't recognise cached bind-mount Docker volume setting #104

Open dvejmz opened 4 years ago

dvejmz commented 4 years ago

Problem summary

cage can't parse pod YML files with a cached bind-mount Docker volume configuration in them and errors as a result. This makes running cage in macOS a bit difficult, due to the limitations inherent to Docker for Mac which are usually alleviated by using this mount flag.

Given that cage generates docker-compose v2.4 files, which support the cached Docker volume configuration, I was expecting this not to be an issue in cage. To verify this, I opened the docker-compose file cage generated for my service in .cage, manually made the change to the volume config and run docker-compose up directly against it without an issue.

Environment

Docker version

Client: Docker Engine - Community
 Version:           19.03.9
 API version:       1.40
Server: Docker Engine - Community
 Engine:
  Version:          19.03.9
  API version:      1.40 (minimum version 1.12)

docker-compose version

docker-compose version 1.22.0, build f46880f
docker-py version: 3.7.0
CPython version: 3.7.7
OpenSSL version: OpenSSL 1.1.1g FIPS  21 Apr 2020

cage version

cage 0.3.0-alpha.3

Operating system

Linux 5.6.13-100.fc30.x86_64 #1 SMP Fri May 15 00:36:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Steps to reproduce

Create a pod definition YML as follows

version: "2"

services:
  my_service:
    build: "./path/to/service/Dockerfile"
    image: "app/my-service:latest"
    entrypoint: bash -c "yarn && yarn start"
    ports:
      - 5000:3000
    volumes:
      - ./path/to/service/app:/app:cached
      - /app/node_modules/

Run any cage command like cage up my-service or cage status.

Actual behaviour

I run any cage command and get the following error back:

Error: could not read '/home/user/dev/project/pods/my-service.yml'
error reading file "/home/user/dev/project/pods/my-service.yml"
services.my_service.volumes: invalid volume permissions "cached" at line 11 column 7

Expected behaviour

Error not to appear and more importantly, cage up my-service to successfully stand up the pod with the volume cached as requested.

Any help with this would be greatly appreciated. I'm happy to submit a PR for this if people think it's a feasible thing to do and it's not overly difficult.

emk commented 4 years ago

This sounds like a really useful feature! Thank you for proposing it.

The changes would actually need to be made here, in the compose_yml library's support for volume mounts: https://github.com/emk/compose_yml/blob/master/src/v2/volume_mount.rs

I don't have time to work on this right now, but I would be happy to mentor somebody who wanted to try making the change.