Lumen does not read env from system during request

Lumen 5.4, MySql & Docker. I have following variables in global env

$ printenv

.env in my project the are present also, but they have different values.

  • Update (pull) all docker images at once
  • Docker-compose: Encountered errors while bringing up the project
  • How to push single docker image layers at time?
  • Phusion Passenger http to https results in redirect loop
  • ctrl-space centos in docker isn't working?
  • Get Docker Container CPU Usage as Percentage
  • If I type in tinker env('DB_HOST'), it prints value from the global environment, but when application runs, it takes from the specified .env file. I think the problem exists within following function in Laravel\Lumen\Application :

     * Load a configuration file into the application.
     * @param  string  $name
     * @return void
    public function configure($name)
        if (isset($this->loadedConfigurations[$name])) {
        $this->loadedConfigurations[$name] = true;
        $path = $this->getConfigurationPath($name);
        if ($path) {
            $this->make('config')->set($name, require $path);

    How to override those values or make it to avoid those conditions: isset($this->loadedConfigurations[$name]) ?

  • Don't have permission to access / on this server (apache2) in docker
  • Docker: Error response from daemon: no such id:
  • connecting Docker on Windows to Google Cloud Datalab
  • Problems getting docker containers to see (ping) each other by name
  • Install PostgreSQL into a core container
  • Docker - archive/tar: write too long
  • One Solution collect form web for “Lumen does not read env from system during request”

    I still think that, regarding my comment, the answer remains the same. If you wish to utilize the docker environment variables as opposed to your local .env variables, then the config directory is still the way to go. In this case, it looks like you wish to target the database host. So let’s do that:

    In your config/database.php file, change the following:

    'mysql' => [
        'host' => getenv('DB_HOST') ?: env('DB_HOST', 'defaultvalue')

    Then only make reference to the host through the config file.


    You will get the ENV from your docker container if it exists, otherwise you will get the DB_HOST declaration from your .env file.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.