Generate swagger Open 'file': permission denied - docker

I tried to generate swagger using this command
swagger generate spec -o ./swagger.yaml --scan-models
but I got error like this :
open ./swagger.yaml: permission denied
I have installed (go-swagger) using docker with version :
version: v0.30.4
commit: df6da9b77aa9751f06bedb17fcf92b1ab67a7a47
and use following command to run the docker
alias swagger='docker run --rm -it --user $(id -u):$(id -g) -e GOCACHE=/tmp -e GOPATH=$(go env GOPATH):/go -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger'
Thanks for any help!!

Related

Docker openapi client generator can't find "spec file"

I have generated a openapi json file, and I wish to create a typescript client using docker.
I have tried to do something similar to what is on the openapi generator site (https://openapi-generator.tech/ - scroll down to docker part), but it doesn't work.
Command from site:
docker run --rm \
-v $PWD:/local openapitools/openapi-generator-cli generate \
-i /local/petstore.yaml \
-g go \
-o /local/out/go
What I have tried:
docker run --rm -v \
$PWD:/local openapitools/openapi-generator-cli generate -i ./openapi.json \
-g typescript-axios
No matter what I do, there is always a problem with the ./openapi.json file. The error which occours:
[error] The spec file is not found: ./openapi.json
[error] Check the path of the OpenAPI spec and try again.
I have tried the things below:
-i ~/compass_backend/openapi.json
-i openapi.json
-i ./openapi.json
-i $PWD:/openapi.json
cat openapi.json | docker run .... (error, -i is required)
I am out of ideas. The error is always the same. What am I doing wrong?
I was able to solve the problem by switching from bash to powershell. Docker uses windows path notation and I was trying to use bash notation. If you type pwd in bash you get this:
/c/Users/aniemirka/compass_backend
And if you type pwd in powershell you get this:
C:\Users\aniemirka\compass_backend
So docker was trying to mount a volume to /c/Users/aniemirka/compass_backend\local, and it couldn't read it because it is not windows notation, so the volume didn't exist.

How to run a tkinter file on Docker in Windows?

I am trying to run a GUI created using tkinter on Docker.
This is the docker run command:
docker run -u=$(id -u $USER):$(id -g $USER) -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v $(pwd)/app:/app --rm tkinter_in_docker
I am getting the error:
unknown shorthand flag: 'g' in -g
See 'docker run --help'.
What is the correct way to run to get the desired results?

Docker : invalid reference format on composer install

I want to install the vendor folder of a project on docker, and I try to use this command:
winpty docker run --rm --interactive --tty \ --volume $(pwd):/app \ composer install
but after running it, I get the error message
C:/Program Files/Docker/Docker/Resources/bin/docker.exe: invalid
reference format.
is there any solution to fix it?
In powershell you should use ${pwd} instead of $(pwd)

How to mount data directory?

I am not able to start percona mysql dockerized instance if I try to mount the data directory like this:
docker run --name percona57f -p 3384:3306 -v /my/custom3384:/etc/mysql/conf.d -v /storage/data3384:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=india3384 -e INIT_TOKUDB=1 -d percona/percona-server:5.7
The error is as shown below:
[ERROR] --initialize specified but the data directory exists and is not writable. Aborting.
[ERROR] Aborting
The command will work if I do not include the data directory like this...
docker run --name percona57g -p 3384:3306 -v /my/custom3384:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=india3384 -e INIT_TOKUDB=1 -d percona/percona-server:5.7
But it is very important for me to mount the data directory on host machine. Any way to enable this -v /storage/data3384:/var/lib/mysql
Run this command before docker run:
chown 1001 /my/custom3384
This is the UID for the mysql user, as shown in the Dockerfile for the percona image:
https://github.com/percona/percona-docker/blob/master/percona-server/Dockerfile
RUN useradd -u 1001 -r -g 0 -s /sbin/nologin \
-c "Default Application User" mysql

Docker Unable to find image '502:20' locally. How can I resolve this issue?

When I run the following command I get the following output message. How can I resolve this issue?
docker run -it --rm "$(id -u):$(id -g)" -v "PWD":/usr/src/app -w /usr/src/app \
rails rails new --skip-bundle --api --database postgresql webapp
Command prints:
Unable to find image '502:20' locally
docker: Error response from daemon: repository 502 not found: does not exist or no pull access.
It looks like you are adding some extraneous items (user and group ids) to your docker run call:
"$(id -u):$(id -g)"
Docker is seeing this as the first positional argument and assuming that it is the repository/image name. Running without that argument should work:
docker run -it --rm -v "PWD":/usr/src/app -w /usr/src/app \
rails rails new --skip-bundle --api --database postgresql webapp

Resources