mauricioklein / docker-compose-api

A Docker Compose parser for Ruby
MIT License
33 stars 25 forks source link

Environment variables not supported in docker-compose.yml #38

Closed autotelik closed 7 years ago

autotelik commented 7 years ago

Description

Seems that support for environment variables in the docker compose file can fail

This is I believe valid configuration, using an Env Var to hold details of a volume. Certainly it works using docker compose command lines but fails in Ruby

data-container:
    image: busybox:1.26
    volumes:
      - ${DOCKER_HOST_DATA_DIR}:/data

How to reproduce

Use an Env variable to hold details of a volume in docker-compose.yml

What do you expect

That the associated value from the environment would replace the place holder and be used by Docker compose to build service

What happened instead

Raises exception

Causes error

Docker::Error::ServerError: create ${DOCKER_HOST_DATA_DIR}: "${DOCKER_HOST_DATADIR}" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9.-]" are allowed

Software:

Full backtrace

Docker::Error::ServerError: create ${DOCKER_HOST_DATA_DIR}: "${DOCKER_HOST_DATA_DIR}" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed

/git/rubystack-2.3.1-6/ruby/lib/ruby/gems/2.3.0/gems/docker-api-1.33.2/lib/docker/connection.rb:50:in `rescue in request'
/git/rubystack-2.3.1-6/ruby/lib/ruby/gems/2.3.0/gems/docker-api-1.33.2/lib/docker/connection.rb:38:in `request'
/git/rubystack-2.3.1-6/ruby/lib/ruby/gems/2.3.0/gems/docker-api-1.33.2/lib/docker/connection.rb:65:in `block (2 levels) in <class:Connection>'
/git/rubystack-2.3.1-6/ruby/lib/ruby/gems/2.3.0/gems/docker-api-1.33.2/lib/docker/container.rb:337:in `create'
  /home/git/docker-compose-api/lib/docker-compose/models/compose_container.rb:96:in `prepare_container'
  /home/git/docker-compose-api/lib/docker-compose/models/compose_container.rb:210:in `start'
autotelik commented 7 years ago

https://github.com/mauricioklein/docker-compose-api/pull/39

mauricioklein commented 7 years ago

Fixed by #36