"Error: couldn't add user" in MongoDB docker stack using a secrets file on Windows - mongodb

While trying to run a MongoDB docker instance with authorization managed by docker-secrets (with files), inspired by this blog post, I kept running into the following error:
2020-07-24T16:25:26.656+0000 E QUERY [js] uncaught exception: Error: couldn't add user: Error preflighting normalization: U_STRINGPREP_PROHIBITED_ERROR :
Setup
Windows machine running docker with a WSL2 backend.
latest mongo image from docker hub (version 4.2.8)
docker secrets to manage the authentication credentials to the MongoDB database
my composer file:
# docker-compose.yml
version: '3.5'
services:
my_db:
image: mongo
command: --auth
environment:
MONGO_INITDB_ROOT_PASSWORD_FILE: /run/secrets/mongodb_root_password
MONGO_INITDB_ROOT_USERNAME_FILE: /run/secrets/mongodb_root_username
secrets:
- mongodb_root_password
- mongodb_root_username
secrets:
mongodb_root_password:
- file: mongodb/.mongodb_root_password
mongodb_root_username:
- file: mongodb/.mongodb_root_username
shell command to deploy docker stack
$ docker stack deploy --compose-file=docker-compose.yml my_db_stack
Problem
Unfortunately, the container kept dying. In the logs, I was able to find the error mentioned above.

It turns out that the problem was caused by Windows-style line endings in the mongodb/.mongodb_root_password and mongodb/.mongodb_root_username files. Those files were created on the Windows host, and then (I assume) were blindly copied to the container.
Solution
Using notepad++ I switched the line endings to Unix-style, which solved the problem.
To switch the line endings, I right-clicked the highlighted portion of the bottom bar in the image below, on Notepad++.

Related

Docker Compose GPU Support: services.*.deploy.resources.reservations Additional property devices is not allowed

Versions of Docker tooling:
Docker Compose version v2.6.0
Docker Engine Version 20.10.17 (client)
Docker Engine Version 20.10.17 (server)
I've got a compose file that starts a swarm with networks and secrets, so I'm using Docker Compose File Version 3.9.
One of my services is a GPU resource, so I added this based on current docs:
version: "3.9"
services:
my-app:
image: my-app:latest
deploy:
resources:
reservations:
devices:
- capabilities: [gpu]
count: all
. . .
My IDE is complaining with "expected scalar value" indicating that it doesn't recognize the key or value of capabilities and count and when I run the command:
docker stack deploy --compose-file docker-compose.yml my-stack
Docker throws an error:
services.prosit-app.deploy.resources.reservations Additional property devices is not allowed
Based on the versions of my Docker tools and the schema I'm using, this should all work (I think). What am missing?
I've tried various file versions and I can get the IDE warning to go away but then Docker can't support the file version. I've tried with and without quotes ["gpu"], different options, etc, to no avail.
This question was asked already (my bad) and the answer was missed by me and others:
Docker Compose returns error about property devices when trying to enable GPU
Reference:
https://docs.docker.com/compose/compose-file/compose-file-v3/#devices

Docker Compose - invalid variable

I have docker compose yml file in my project file.
When try to run the below commend i get the below error.
docker-compose up
I get the below error message
invalid variable name "docker-compose.yml"
I have installed and uninstalled docker multiple times.
my Docker version - Docker version 20.10.8, build 3967b7d
my docker-compose version - Docker Compose version v2.0.0-rc.3
Check that your environment variables or .env file does not contain multiline variables (e.g. SSH keys). After flattening them, error should disappear. Source: https://github.com/Azure/aci-deploy/issues/29

unable to read config after upgrade to envoy 1.15

I'm using Envoy docker image in docker-compose. Docker is running in Ubuntu, which is running in VM, which is running in Windows 10.
I have been using Envoy 1.14 without any problems. After upgrading image to 1.15, Envoy doesn't start and I'm getting this error:
unable to read file: /etc/envoy/envoy.yaml
line before this one says basically the same:
[critical][main] [source/server/server.cc:101] error initializing configuration '/etc/envoy/envoy.yaml': unable to read file: /etc/envoy/envoy.yaml
My docker-compose part for Envoy is simple:
envoy:
image: envoyproxy/envoy:v1.15-latest
container_name: envoy
restart: always
volumes:
- "~/envoy.yaml:/etc/envoy/envoy.yaml:ro"
If I just change envoyproxy/envoy:v1.15-latest to envoyproxy/envoy:v1.14-latest and do docker-compose down && docker-compose up, everything works fine. Are there any special permissions for config file now? Or is it something during my upgrade process?
Solved in github issue: https://github.com/envoyproxy/envoy/issues/12747#issuecomment-677485704
Solution: change permissions for envoy.yaml (chmod 777 is working fine for me).

How to run Mongo container on Windows Server 1809

I'm trying to run a mongodb container on Windows Server 1809 but am getting the following error:
docker run --name mongodb --restart unless-stopped -d -p 27017:27017 mymongo
docker: Error response from daemon: hcsshim::CreateComputeSystem bf9bf4086726d00cbcaff1f082e6b1db12bd803f3ba2c2ca7c0db1e5d75aa316: The container operating system does not match the host operating system.
(extra info: {"SystemType":"Container","Name":"bf9bf4086726d00cbcaff1f082e6b1db12bd803f3ba2c2ca7c0db1e5d75aa316","Owner":"docker","VolumePath":"\\\\?\\Volume{452442a7-ac87-4117-8e82-b00a8d87b444}","IgnoreFlushesDuringBoot":true,"LayerFolderPath":"C:\\ProgramData\\docker\\windowsfilter\\bf9bf4086726d00cbcaff1f082e6b1db12bd803f3ba2c2ca7c0db1e5d75aa316","Layers":[{"ID":"fc52f55a-6f1e-5651-93c6-09c1fcaf7c9a","Path":"C:\\ProgramData\\docker\\windowsfilter\\c9035a2f08cd42f11c3c76895b03021b6d48266d0f86bd083c12fa5f86455e60"},{"ID":"ab78d923-9c41-55fc-92ec-a9330d5db560","Path":"C:\\ProgramData\\docker\\windowsfilter\\c01be26c30f8769641fe00741c162d71bb3305df4c71cbaf138ff2b901ec6b11"},{"ID":"026d80b8-19b3-5c4d-ae3d-35a54251fe3e","Path":"C:\\ProgramData\\docker\\windowsfilter\\def72c2b739b9f453610c44a8ed61e997306eaf34a2ecddd00198d0e7a002f97"},{"ID":"3f241ae1-ba2c-5fec-8d70-c2396e176817","Path":"C:\\ProgramData\\docker\\windowsfilter\\c7cedcded6a8aa587cef67edb4918bec61be7a3500892ea1e96ff7b2c3e13af2"},{"ID":"2efd8648-ea16-508d-8c5b-6a0ef3e6c84d","Path":"C:\\ProgramData\\docker\\windowsfilter\\60049935b45a47f9649619a2f5bcd87d9b9a909452c3bd0fbd1a6a7275bcb7b0"},{"ID":"eddd0e96-fd43-58c7-94fc-530892d35234","Path":"C:\\ProgramData\\docker\\windowsfilter\\80f9aa5efa51e2fa9b068a68b4b5dd5a4b10724cdeab62238dfe7d3f123767d1"},{"ID":"11f58e92-5415-5594-9910-9ff4f59731fb","Path":"C:\\ProgramData\\docker\\windowsfilter\\65f94285263b26ecb465ede59d13113b09e2e31891fc832e2700c00a5902c147"},{"ID":"cedb9cc2-9b4c-5175-bd37-f74b69253886","Path":"C:\\ProgramData\\docker\\windowsfilter\\95cb73e37cc8f93d5e63143c0d0de000cc1af77e498108babaf5ceebd09cebf0"},{"ID":"745ef0c5-ae72-5e25-b6bb-7208c533560e","Path":"C:\\ProgramData\\docker\\windowsfilter\\8984fb6ffe0575d27d836a764d64591ae175272a75260ee476507100618d3b78"},{"ID":"b0dcfd28-95d6-506d-bbcf-48e5f62ef97f","Path":"C:\\ProgramData\\docker\\windowsfilter\\e747665dffb09875cdeeb4438a422f2c6a3a83f3d30f1d77001e19a078ec3392"},{"ID":"f2fb9c30-cdca-513e-8409-c21af8fbfcaa","Path":"C:\\ProgramData\\docker\\windowsfilter\\f5641e2fbb273e21e654e8671af314de80a62f5a5074cfdb3a7784f296c6d171"},{"ID":"67e9a990-1ee4-597f-8e73-ee95b6f65d30","Path":"C:\\ProgramData\\docker\\windowsfilter\\e18aba5da9d71b86e113123d6635fcec544f1228b6c29e76b7027ed1d5b207d7"},{"ID":"741cd5e2-3dfe-5693-ba08-ac8fed4ae741","Path":"C:\\ProgramData\\docker\\windowsfilter\\6029438e12ce66ab4f7b48ca5f7aa10ff6d1b284602f2f6fa0ab2b56daa96796"}],"HostName":"bf9bf4086726","MappedDirectories":[{"HostPath":"C:\\ProgramData\\docker\\volumes\\e1898e25db59a589102c266339cc21243e62ba950a70a82f6b3fc31d693f1494\\_data","ContainerPath":"c:\\data\\configdb","ReadOnly":false,"BandwidthMaximum":0,"IOPSMaximum":0,"CreateInUtilityVM":false},{"HostPath":"C:\\ProgramData\\docker\\volumes\\e42d0b5e649c60b87b7ff283b0db51f28d95cf1e9b2ef33ddb50344bf61358b7\\_data","ContainerPath":"c:\\data\\db","ReadOnly":false,"BandwidthMaximum":0,"IOPSMaximum":0,"CreateInUtilityVM":false}],"HvPartition":false,"EndpointList":["A64F960D-CB2B-4452-8438-2A1E25105432"],"AllowUnqualifiedDNSQuery":true}).
I tried with both 4.2.1-windowsservercore-1803 and 4.2.1-windowsservercore-ltsc2016. I also tried using isolation=hyperv, but it gave me "Request is not supported". On another Windows Server, this one 2016, everything worked.
What can I do to run a mongo container on windows server 1809?
I got it working by copying the image for the MongoDB version I wanted on their github and changing the FROM line to
FROM mcr.microsoft.com/windows/servercore:1809

Docker compose - secrets Additional property secrets is not allowed

docker-compose --version
docker-compose version 1.11.1, build 7c5d5e4
I have secret 'my_secret_data' added to my swarm cluster:
The start of my compose file looks like:
version: "3.1"
secrets:
my_secret_data:
external: true
services:
master:
image: jenkins-master
secrets:
- my_secret_data
ports:
- "8080:8080"
- "50000:50000"
'docker stack deploy' continually gives the error:
secrets Additional property secrets is not allowed
I have followed how do you manage secret values with docker-compose v3.1? to the letter as far as I can tell and have the correct versions installed but keep getting the above error. Any help greatly appreciated.
Change compose file version to latest version.
In short, version '3' is not resolved to the latest '3.x' version. Find what the latest version is here https://docs.docker.com/compose/compose-file/#compose-and-docker-compatibility-matrix
The "Additional property secrets is not allowed" error can be caused either by:
running Docker Engine < 1.13.1, or
using a compose file version number < '3.1' in a docker-compose file such as docker-compose.yml or docker-cloud.yml
If you are experiencing this problem confirm that both are correct.
This also applies to other Docker interfaces and tools.
For examples, in Portainer, yml with secrets lines pasted into the Create Stack dialog should begin with the line version: '3.1' or you will encounter the same error -- even with an up-to-date Docker Engine 1.13.1+.
In my case, Service: had an extra tab prior. Moment I removed tab prior to it, it worked.