docker-compose contains an invalid type - docker

In my docker-compose.yml I'm getting an error when I run docker-compose up
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.pulsar.ports contains an invalid type, it should be a number, or an object
I believe the problem lies with this line:
ports:
- "${HOST_PULSAR_PORT}:8999"
I'm not understanding the syntax of ${PORT_NAME} or what the error is taking issue with exactly...

Related

Cypress - The plugins file is missing or invalid running on Docker

I add this import - const { addMatchImageSnapshotPlugin } = require("cypress-image-snapshot/plugin");
into file cypress/plugins/index.js.
And error is thrown while running on Docker:
Your `pluginsFile` is set to `/cypress/plugins/index.js`, but either the file is missing, it contains a syntax error, or threw an error when required. The `pluginsFile` must be a `.js`, `.ts`, or `.coffee` file.
It works perfectly when I'm running the specs locally but strangely it fail when they are runned on the docker image.
`

What is the syntax for ELASTICSEARCH_HOSTS in docker-compose?

Trying to figure out Kibana's ELASTICSEARCH_HOSTS syntax, but I receive either:
kib01 | FATAL Error: [config validation of [elasticsearch].hosts]: types that failed validation:
kib01 | - [config validation of [elasticsearch].hosts.0]: expected URI with scheme [http|https].
kib01 | - [config validation of [elasticsearch].hosts.1]: could not parse array value from json input
from Kibana itself or:
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.kibana.environment.ELASTICSEARCH_HOSTS contains ["http://es01:9200", "http://es02:9200", "http://es03:9200", "http://es04:9200"], which is an invalid type, it should be a string, number, or a null
from Docker compose.
My latest iteration is:
environment:
ELASTICSEARCH_HOSTS=["http://es01:9200", "http://es02:9200", "http://es03:9200", "http://es04:9200"]
I have also tried:
environment:
- ELASTICSEARCH_HOSTS: '["http://es01:9200", "http://es02:9200", "http://es03:9200", "http://es04:9200"]'
I tried turning that into a list:
environment:
ELASTICSEARCH_HOSTS:
- "<host1>"
- "<host2>"
I tried removing quotes in various places in the above variation and various combinations on the list.
I also tried a combination from the official documentation using both : and =
with ELASTICSEARCH_HOST = http://es01:9200, http://es02:9200...
All have been rejected. Does anyone know the magic syntax to get this to work?
Updated List of failures:
ELASTICSEARCH_HOSTS: ['http://es01:9200','http://es02:9200','http://es03:9200','http://es04:9200']
ELASTICSEARCH_HOSTS="['http://es01:9200','http://es02:9200','http://es03:9200','http://es04:9200']"
- ELASTICSEARCH_HOSTS=['http://es01:9200','http://es02:9200','http://es03:9200','http://es04:9200']
- ELASTICSEARCH_HOSTS="["http://es01:9200","http://es02:9200","http://es03:9200","http://es04:9200"]"
ELASTICSEARCH_HOSTS:
- "<host1>"
- "<host2>"
There are some things to note to solve your problem:
In docker-compose, your environment variables must be written as an object, or an array:
# A native yaml approach to define key-value objects
environment:
KEY1: VAL1
KEY2: VAL2
# OR
# Some special way for compose yaml parser
# that can split key and value from a "KEY=VAL" string
environment:
- KEY1=VAL1
- KEY2=VAL2
The value of an environment variable must be a string (the above example), a number, or null (empty value). Note that [foo, bar] is parsed as a list in the first format (and if you want it to be parsed as a string, you need to wrap it inside quotation marks), but the second format parses it as a string.
In this forum question, there is an example to how pass multiple elasticsearch hosts as an environment variable (ELASTICSEARCH_HOSTS).
So this must be a valid example that docker-compose and Kibana can both understand:
environment:
ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200","http://es04:9200"]'
# OR
environment:
- ELASTICSEARCH_HOSTS=["http://es01:9200","http://es02:9200","http://es03:9200","http://es04:9200"]

Docker-compose variable-substitution mandatory variables

I have a docker-compose file that uses variable substitution for some secrets and I want to get an error if they are not supplied or empty, for this purpose I have tried this:
environment:
- >-
JAVA_OPTS=
-DMYSQL_USER=${MYSQL_USER:?MYSQL_USER_NOT_SET}
-DMYSQL_PASSWORD=${MYSQL_PASSWORD:?MYSQL_PASSWORD_NOT_SET}
-DMYSQL_URL=db:3306/${MYSQL_DATABASE:?MYSQL_DATABASE_NOT_SET}
However, it gives me the error:
ERROR: Invalid interpolation format for "environment" option in service "myservice": "JAVA_OPTS= -DMYSQL_USER=${MYSQL_USER:?MYSQL_USER_NOT_SET}...
According to https://docs.docker.com/compose/compose-file/#variable-substitution this should work since it has this snippet:
Similarly, the following syntax allows you to specify mandatory
variables:
${VARIABLE:?err} exits with an error message containing err if
VARIABLE is unset or empty in the environment. ${VARIABLE?err} exits
with an error message containing err if VARIABLE is unset in the
environment.
I also have version: "3.4" in my docker-compose so that shouldn't be the issue.
Already tried it with just ${MY_VAR?MY_ERROR} but it didn't work either.
I have even gone as far as to look at the source code but found nothing helpful.
EDIT :
I tried to make a minimum size reproduction:
docker-compose.yml
version: "3.4"
services:
hello:
image: hello-world
environment:
- TEST=${TEST?err}
docker-compose up
ERROR: Invalid interpolation format for "environment" option in service "hello": "TEST=${TEST?err}
This depends on your docker-compose version.
With docker-compose 1.17.1 you will get
ERROR: Invalid interpolation format for "environment" option in service "my-service": ...
if you use ${TEST?"My error message"} but with
e.g. docker-compose 1.29.2 it works as expected
ERROR: Missing mandatory value for "environment" option interpolating ... in service "my-service": "My error message"

Hadoop/Yarn Docker-Container-Executor fails because of "Invalid docker rw mount"

I am trying to execute the simple example for the Hadoop/Yarn (Version: 2.9.1) Docker-Container-Executor:
vars="YARN_CONTAINER_RUNTIME_TYPE=docker,YARN_CONTAINER_RUNTIME_DOCKER_IMAGE=hadoop-docker"
hadoop jar hadoop-examples.jar pi -Dyarn.app.mapreduce.am.env=$vars -Dmapreduce.map.env=$vars -Dmapreduce.reduce.env=$vars 10 100
Unfortunately the job fails with the following exception:
Failing this attempt.Diagnostics: [2018-09-08 22:23:54.288]Exception from container-launch.
Container id: container_1536441225683_0004_02_000001
Exit code: 29
Exception message: Invalid docker rw mount '/tmp/hadoop-hadoop/nm-local-dir/usercache/hadoop/appcache/application_1536441225683_0004/:/tmp/hadoop-hadoop/nm-local-dir/usercache/hadoop/appcache/application_1536441225683_0004/', realpath=/tmp/hadoop-hadoop/nm-local-dir/usercache/hadoop/appcache/application_1536441225683_0004/
Error constructing docker command, docker error code=14, error message='Invalid docker read-write mount'
Anybody has an idea how to solve the Invalid docker read-write mount?
Solved by adding this directory to property docker.allowed.rw-mounts in etc/hadoop/container-executor.cfg. If you get error message for multiple directories they need to be added comma seperated.
In my case:
docker.allowed.rw-mounts=/usr/local/hadoop/,/var/hadoop/yarn/local-dir,/var/hadoop/yarn/log-dir,/tmp/hadoop-hadoop/

Nominatim failes with "Illegal query string"

I'm currently installing Nominatim using the Docker image that can be found at https://github.com/bringnow/docker-nominatim . However, when I send a query I get the following error:
Bad Request
Nominatim has encountered an error with your request.
Details: Illegal query string (not an UTF-8 string): paderborn
When I have a look at the console, I get the following error:
ERROR: relation "query_log" does not exist at character 13
STATEMENT: insert into query_log values ('2018-05-23 15:25:03.9961','paderborn','172.18.0.1')
ERROR: relation "new_query_log" does not exist at character 13
STATEMENT: insert into new_query_log (type,starttime,query,ipaddress,useragent,language,format) values ('search','2018-05-23 15:25:03.9961','q=paderborn&polygon=1&viewbox=','172.18.0.1','Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0','short_name:de,short_name:en-US,short_name:en,name:de,name:en-US,name:en,place_name:de,place_name:en-US,place_name:en,official_name:de,official_name:en-US,official_name:en,short_name,name,place_name,official_name,ref,type','')
ERROR: function make_standard_name(unknown) does not exist at character 8
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
STATEMENT: select make_standard_name('paderborn') as string
I already found an answer that proposes the following solution:
./utils/setup.php --create-functions --enable-diff-updates
However, this results in an error:
Functions
CREATE FUNCTION
ERROR: could not access file "/app/module/nominatim.so": No such file or directory
When I have a look at the file system, the file nominatim.so exists. So, this error is confusing.
Does anyone know a solution for that?
I found the mistake: We have two docker images, one for nominatim and one for postgis. The file /app/module/nominatim.so is created inside the nominatim image but also needed within the postgis image. The solution is to create a volume that allows to share the file.
Within docker-compose.yaml add the following lines to the nominatim service:
volumes:
- ./volumes/module:/mnt/module
and the following lines within postgis service:
volumes:
- ./volumes/module:/app/module
Further extend the entrypoint.sh:
log_info "==> Copy nominatim.so"
cp /app/module/nominatim.so /mnt/module/nominatim.so
Note that you have to rebuild the nominatim Docker image.

Resources