Giter Club home page Giter Club logo

compose_yml's People

Contributors

camjackson avatar emk avatar khuey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

compose_yml's Issues

Add support for `docker-compose.yml` version 2.1

This is about to be released, and we need to support it. There's a bunch of (minor) new features here, some of which will be helpful.

New features, according to the release notes:

  • Added support for setting volume labels and network labels in docker-compose.yml.
  • NOPE (undocumented). Added support for the isolation parameter in service definitions.
  • NOPE (obscure). Added support for link-local IPs in the service networks definitions.
  • Added support for shell-style inline defaults in variable interpolation. The supported forms are ${FOO-default} (fall back if FOO is unset) and ${FOO:-default} (fall back if FOO is unset or empty).
  • Added support for the group_add and oom_score_adj parameters in
    service definitions.
  • Added support for the internal and enable_ipv6 parameters in network definitions.
  • Overriding a logging configuration will now properly merge the options mappings if the driver values do not conflict.

Special volume paths in Docker for Windows

Docker for Windows allows to specify special paths in volumes sub-section of service section. These paths must NOT be converted to Windows equivalent. Examples:

services:
    test:
        volumes:
            - /dev/shm:/dev/shm
            - /var/run/docker.sock:/var/run/docker.sock
            - "/sys:/sys:ro"
            - "/var/run:/var/run:rw"

Fix handling of Windows host paths in `docker-compose.yml`

Much to my surprise, it looks like compose_yml is very close to working on Windows! But to fully support Windows, we'd need to make a number of changes.

Inside the container: Represent container paths with a new type

The following fields assume that the path format inside a container is the same as the path format on the host OS:

struct Service {
    pub working_dir: Option<RawOr<PathBuf>>,
pub struct VolumeMount {
    /// Where should we mount this volume in the container?  This must be
    /// an absolute path.
    pub container: PathBuf,

We could just make a trivial wrapper type named ContainerPathBuf around String and use that to replace all these instances of PathBuf, since we treat these fields as almost entirely opaque and we don't seem to need any Path operations on them. Or we could be lazy and just replace these with String.

Outside the container: Figure our how Windows paths work with docker-compose.yml

The first three fields are relatively easy, and we probably don't need to change anything:

enum Context {
    /// A regular local directory.
    Dir(PathBuf),
struct Service {
    pub env_files: Vec<RawOr<PathBuf>>,
struct Extends {
    pub file: Option<RawOr<PathBuf>>,

But the final field is going to require careful investigation:

enum HostVolume {
    /// This volume corresponds to a path on the host.  It may be a
    /// relative or absolute path.
    Path(PathBuf),
    /// A path relative to the current user's home directory on the host.
    /// Must be a relative path.
    UserRelativePath(PathBuf),

On Unix, this field can represent several different kinds of host paths:

version: "2"
services:
  voltest:
    image: "faraday/rails_hello"
    command: ["bash"]
    volumes:
      - "/absolute/path:/mnt/a"
      - "/absolute/path:/mnt/b:ro"
      - "./relative/path:/mnt/c"
      - "~/user/relative/path:/mnt/d"

If I save this as vol-test.yml and I run this with:

docker-compose -f vol-test.yml run voltest`

Then I can run the following inside the container:

root@2cd832d24351:/usr/src/app# ls /mnt/
a  b  c  d

I'd like to translate the above file to work natively on Windows, with particular attention paid to making sure the absolute and relative paths work correctly, and actually map to the expected directories on disk. In particular, what does an absolute path on the C: drive need to look like to get mounted into a container?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.