Docker Compose - invalid variable - docker-compose

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

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

Deploy a private image inside minikube on linux

I am starting to use kubernetes/Minikube to deploy my application which is currently running on docker containers.
Docker version:19.03.7
Minikube version: v1.25.2
From what I read I gather that first of all I need to build my frontend/backend images inside minikube.
The image is available on the server and I can see it using:
$ docker image ls
The first step, as far as I understand, is to use the "docker build" command:
$docke build -t my-image .
However, the dot at the end, so I understand, means it is looking for a Dockerfile in the curretn directoy, and indeed I get an error:
unable to evaluate symlinks in Dockerfile path: lstat
/home/dep/k8s-config/Dockerfile: no such file or directory
So, where do I get this dockerfile for the "docker build" to succeed?
Thanks
My missunderstanding...
I have the Dockefile now, so I should put it anywhere and use docker build from there.

docker-compose: Not accepting extensions starting with "x-" (Invalid top-level property "x-...")

I'm trying to deploy a service which uses docker-compose files and I've been seeing the following error:
Invalid top-level property "x-...". Valid top-level sections for this Compose file are: secrets, version, volumes, services, configs, networks, and extensions starting with "x-".
You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions ...
I reproduced the error using this simple docker-compose.yml file:
version: "3.5"
x-secrets: &secrets
secrets:
- foo
services:
a:
<<: *secrets
image: a-image
secrets:
foo:
external: true
The command
docker-compose -f docker-compose.yml up
Gives the following output:
ERROR: The Compose file './docker-compose.yml' is invalid because:
Invalid top-level property "x-secrets". Valid top-level sections for this Compose file are: secrets, version, volumes, services, configs, networks, and extensions starting with "x-".
You might be seeing this error because you're using the wrong Compose file version. Either specify a supported version (e.g "2.2" or "3.3") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
Versions:
docker --version
Docker version 19.03.6, build 369ce74a3c
docker-compose --version
docker-compose version 1.17.1, build unknown
Running on Ubuntu 18.04.
Thanks for any input!
Resolved this by upgrading docker-compose to
docker-compose version 1.27.4, build 40524192
This means that either the format of your docker-compose.yml file is not correct or your version of docker-compose is too old.
It's always a good practice to upgrade to the latest version of docker-compose - you can do it like this:
Get the latest version
VERSION=$(curl https://api.github.com/repos/docker/compose/releases/latest | jq .name -r)
Install it
sudo curl -L "https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Give system permissions
sudo chmod +x /usr/local/bin/docker-compose
Logout, then login again
Now that you have the latest version, check if the format of your docker-compose.yml file is correct by comparing it to the examples in the official documentation (again, check the format for the latest version). Note that small things like single- vs double-space and different special characters matter a lot!

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

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++.

keda func deploy from a dir which contains spaces is failing

I am using Visual Code with Azure Core Tools to deploy a container to a K8S cluster which has KEDA installed. But seeing this docker error. The error is caused because the docker build is run without the double quotes.
$ func kubernetes deploy --name bollaservicebusfunc --registry sbolladockerhub --python
Running 'docker build -t sbolladockerhub/bollaservicebusfunc C:\Users\20835918\work\welcome to space'....done
Error running docker build -t sbolladockerhub/bollaservicebusfunc C:\Users\20835918\work\welcome to space.
output:
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
(.venv)
20835918#CROC1LWPF1S99JJ MINGW64 ~/work/welcome to space (master)
I know there is a known bug Spaces in directory
But posting to see if there is a workaround, this is important as I have eveything in Onedrive - Comapny Name and it has spaces in it
Looking into the code for func, you could specify --image-name instead of --registry which seems to skip building the container.
You would have to build your docker container manually using the same code shown in the output and provide the value for the -t argument of the docker command for --image-name of the func command after.
Also, since this would not push your docker container as well, make sure to push it before running the func command.