[systemd-devel] Pass environment variables down to systemd-service in container

Lennart Poettering lennart at poettering.net
Sun Jun 14 15:32:09 PDT 2015


On Fri, 12.06.15 17:50, Peter Paule (systemd-devel at fedux.org) wrote:

> Hi there,
> 
> is there a chance to pass (the given) environment variables down to
> `unicorn` and `delayed_job-worker`?
> 
>     systemd (host)
>       |
>        - docker-app.service
>          Environment="RAILS_ENV=production"
>          Environment="DATABASE_URL=postgresql://localhost/app_development"
>           |
>            - docker
>               |
>                - systemd (container)
>                   |
>                    - unicorn (ruby)
>                   |
>                    - delayed_job-worker (ruby)
> 
> Background:
> 
> I need to wrap a rails application within CentOS-image. To make the image
> re-usable I decided to use the DATABASE_URL-environment variable to configure
> the database. I also need to switch the RAILS_ENV.
> 
> I'm using this image here
> https://registry.hub.docker.com/u/feduxorg/centos/dockerfile/. It's based on
> the official docker image which uses the `systemd-container`-package from
> CentOS.

Nope, we deliberately clean up the env block we pass to services.

You can reimport the env vars though by reading them from
/proc/1/environ. Needs some manual hackery though... 

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list