Docker: Error parsing configuration files, file does not exist - docker

I am following a tutorial and using sqlc in my project. However, it's weird that I seem to mount an empty volume. After checking another post mounting the host directory, I found docker creates another empty folder, confirming that I did something wrong about it. Docker documentation doesn't help resolve this issue. Currently, my command with bash terminal:
docker run --rm -v $(pwd)://src -w //src kjconroy/sqlc init
docker run --rm -v $(pwd)://src -w //src kjconroy/sqlc generate
The first command runs successfully but creates another empty folder. The built container is running, and it's path is: \\wsl$\docker-desktop-data\data\docker\volumes on my Windows 10. However, the folder structure is different from the tutorial when I download the desktop docker, so I'll add extra information about how I construct the setting. The construction is using Make with docker:
postgres:
docker run --name postgreslatest -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=secret -d postgres
createdb:
docker exec -it postgreslatest createdb --username=root --owner=root simple_bank
dropdb:
docker exec -it postgreslatest dropdb simple_bank
migrateup:
migrate -path db/migration -database "postgresql://root:secret#localhost:5432/simple_bank?sslmode=disable" -verbose up
migratedown:
migrate -path db/migration -database "postgresql://root:secret#localhost:5432/simple_bank?sslmode=disable" -verbose down
.PHONY: postgres createdb dropdb migrateup migratedown
Any help is appreciated.

I got it working. First of all, I still have no idea why bash command cannot correctly locate the sqlc.yaml file. However, under Windows 10 OS, I succeeded locate and generating files with the command provided by docs.
The command is: docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate using ONLY CMD and the command also works combined with the MakeFile.

Related

racadm - ERROR: Specified file <filename> does not exist

I'm trying to run racadm both in Windows Powershell using the official utility and on my Mac using this Docker container. In both instances, I can pull the RAC details, so I know my login and password are valid, but when I try to perform an sslkeyupload, I get the following error:
ERROR: Specified file file.pem does not exist.
The permissions on the file, at least on my Mac, are wide open (chmod 777) and are in the same directory I'm trying to run the script in:
docker run stackbot/racadm -r 10.10.1.4 -u root -p calvin sslkeyupload -t 1 -f ./file.pem
Anyone see anything obvious I may be doing wrong?
You're running the command inside a Docker container. It has no visibility to your local filesystem unless you explicitly expose your directory inside the container using the -v command line option:
docker run -v $PWD:$PWD -w $PWD ...
The -v option creates a bind mount, and the -w option sets the working directory.

Running google automl‘s custom model locally using docker fails to find path /tmp/mounted_model/0001

I have been working on a ML model to classify some images. After saving the model I have exported it to my machine using gsutil and have set the environment for the container as specified in google‘s documentation. I am doubting there is something wrong with the following command:
sudo docker run --rm --name ${CONTAINER_NAME} -p ${PORT}:8501 -v ${YOUR_MODEL_PATH}:/tmp/mounted_model/0001 -t ${CPU_DOCKER_GCR_PATH}
I do not really understand what does the :/tmp/mounted_model/0001 stands for. Is it something automatically created? I even tried creating a folder in that directory and putting a the .pb model inside but error keeps occuring.
Please let me know if there is any solution for this issue. Thanks!
I had the same issue and the problem was in how I exported YOUR_MODEL_PATH.
That environment must be the folder path that contains saved_model.pb file
So, you have to download the saved_model.pb file into your machine.
gsutil gs://your_model_path/tf_saved_model-object-detection_20211124040443-2021-11-25T13:34:28.736944Z/ local_model_path
export YOUR_MODEL_PATH=local_model_path
Remember: local_model_path is a directory that inside contains the save_model.pb file.
Then run the command that you run before:
sudo docker run --rm --name ${CONTAINER_NAME} -p ${PORT}:8501 -v ${YOUR_MODEL_PATH}:/tmp/mounted_model/0001 -t ${CPU_DOCKER_GCR_PATH}

How to run commands in Docker container

Hello I m trying to follow the step by step guid to build jpeg xl (I m on windows and try to build a x64 version for linux)
after:
docker run -u root:root -it --rm -v C:\Users\fred\source\tools\jpegxl\jpeg-xl-master -w /jpeg-xl gcr.io/jpegxl/jpegxl-builder
I have the container running but I don't know how to run the command inside :
CC=clang-6.0 CXX=clang++-6.0 ./ci.sh opt
I tried CC=clang-6.0 CXX=clang++-6.0 ./ci.sh opt and I get ./ci.sh: No such file or directory no command seems to work when I do "ls" it display nothing
Does someone knows how to get this to build?
Make sure that you start a bash terminal inside the container:
docker run -it <image> /bin/bash
I believe /bin/bash is missing from your docker run command. As a result, you are executing the command for clang inside your own environment, not the container.
You can set the environment variables by using -e
Example
-e CC=clang-6.0 -e CXX=clang++-6.0
The full command to log in into your container:
docker run -u root:root -it --rm -e CC=clang-6.0 -e CXX=clang++-6.0 -v C:\Users\fred\source\tools\jpegxl\jpeg-xl-master -w /jpeg-xl gcr.io/jpegxl/jpegxl-builder /bin/bash
They have updated the image without updating the command so the command is
CC=clang-7 CXX=clang++-7 ./ci.sh opt
The discution is here:
Can't build from docker image "Unknown clang version"

Docker: how to map host directory?

I am trying to reproduce steps to create an Ubuntu based image + nginx, described there:
https://www.howtoforge.com/tutorial/how-to-create-docker-images-with-dockerfile/
My host machine is Windows.
The image is built, then I have created d:\webroot folder on host, index.html file inside and try to run
docker run -v /d/webroot:/var/www/html -p 80:80 --name doom nginx_image
standard_init_linux.go:211: exec user process caused "no such file or directory"
What may be the reason and how to fix it?
The issue is with the start.sh script which is loaded from Windows. Excerpt below:
#!/bin/sh
/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
You need to change the change line ending from CRLF to LF for the start.sh.
And then run: docker run -v /d/webroot:/var/www/html -p 80:80 --name doom nginx_image

Pycharm docker run configuration do not accept environment variables

I am trying to set up a docker run configuration in Pycharm, i am pretty new to this functionality in pycharm, and i can't get it working.
In docker I would run the container with the following command
docker build -t test-container . && docker run --name container-pycharm -t -i --env-file .env -v $(pwd):/srv/app -p 8080:8080 --rm test-container ./serve-app
I set up this in pycharm, by adding the following line
--rm --env-file .env -i -t -p 8080:8080 -v $(pwd):/srv/app
to command line options section in the relevant docker Run/Debug Configuration Pycharm window. Unfortunately I get
Failed to deploy 'container-pycharm Dockerfile: Dockerfile': com.github.dockerjava.api.exception.BadRequestException: {"message":"create $(pwd): \"$(pwd)\" includes invalid characters for a local volume name, only \"[a-zA-Z0-9][a-zA-Z0-9_.-]\" are allowed. If you intended to pass a host directory, use absolute path"}
Clearly, I cant use $(pwd) in my command line options, any idea on how to solve this in pycharm?
Pycharm doesn't invoke docker directly via the command you see in the command preview, it goes through its custom parser, currently they haven't implemented the feature to read envs. Thus "If you intended to pass a host directory, use absolute path"
And -v is not officially supported as command line options in the current version. Ref
Use Bind mounts instead

Resources