arquillian / arquillian-cube

Control (docker, kubernetes, openshift) containers in your tests with ease!
http://arquillian.org/arquillian-cube/
120 stars 98 forks source link

Docker Volumes paths must be normalized and expanded #1100

Closed AndyGee closed 5 years ago

AndyGee commented 5 years ago
Issue Overview

Volumes binding paths need to be normalized and expanded to be compliant with the Docker API. This is especially true for Win plaforms.

Ideally the binding:volume paths must be defined with a full path like so:

  proxy:
    image: nginx:1.15.5
    ports:
     - 80:80
    volumes:
     - //C/Users/Andy/GitHub/full/path/to/e2e/proxy:/etc/nginx/conf.d/

A full path does not make for a good test scenario on other machines. So the common solution is to use a relative path:

    volumes:
     - ./proxy:/etc/nginx/conf.d/

This actually works fine using docker-compose because the binding path is expanded by docker-compose, but in Cube the path is passed as is, and is resolved by Docker-Java to a binding of just proxy - This path does not exist for Docker, and the binding is silently dropped (The volume is not mounted).

Expected Behaviour

The binding path should be expanded and resolved (Especially on Win platforms) before passing to Docker-Java:

    volumes:     
     - ./proxy:/etc/nginx/conf.d/
Current Behaviour

The full path needs to be specified. On Win platforms a special syntax is also required in place of a drive letter (//C/ = C:).

    volumes:
     - //C/Users/Andy/some/app/full/path/to/e2e/proxy:/etc/nginx/conf.d/
Steps To Reproduce
  1. On any platform, but especially Win.
  2. Define a relative binding/volume in a compose file like above (with some local files to verify).
  3. Run a Cube test that loads the compose file to a breakpoint
  4. docker exec -it /bin/bash
  5. Check the mount and see it is not mounted as expected (no files to verify)
  6. Repeat using a full path and see that it is mounted (and the files are available)