HiveBrain v1.2.0
Get Started
← Back to all entries
patterndockerModerate

docker-compose invalid type, it should be a string

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
dockertypecomposeshouldinvalidstring

Problem

I have the following environment variable configured in a docker-compose.yml file:

version: '3'
services:
  server:
    ports:
     - 13045:3000
    environment:
     - NODE_CONFIG: '{"DATABASE_URL":"http://db:5984"}'


When trying to run docker-compose up, I'm getting this error:

services.server.environment contains {"NODE_CONFIG": "{\"DATABASE_URL\":\"http://db:5984\"}"}, which is an invalid type, it should be a string


I need the environment variable to be set to a JSON string (see https://github.com/lorenwest/node-config/wiki/Environment-Variables#node_config)

Am I doing something wrong here? Can I get this to work somehow?

Solution

The Docker Compose file reference states, that environment variables are defined as VARIABLE=value array elements. For your case, the docker-compose.yml file would need to be changed to this:

version: '3'
services:
  server:
    ports:
     - 13045:3000
    environment:
     - NODE_CONFIG='{"DATABASE_URL":"http://db:5984"}'

Code Snippets

version: '3'
services:
  server:
    ports:
     - 13045:3000
    environment:
     - NODE_CONFIG='{"DATABASE_URL":"http://db:5984"}'

Context

StackExchange DevOps Q#1390, answer score: 17

Revisions (0)

No revisions yet.