/bin/bash: scripts/script.sh: Permission denied - docker

I am testing how to install a sample network for Hyperledger Fabric. when I was running 'byfn.sh' inside the 'first-network' project, the console will prompt such error:
/bin/bash: scripts/script.sh: Permission denied
it looks like this line produces above error:
docker exec cli scripts/script.sh $CHANNEL_NAME $CLI_DELAY $LANGUAGE $CLI_TIMEOUT $VERBOSE
I used root user, and have used chmod +x or u+x to change all *.sh files permission. but doesn't work, so any ideas? many thanks!!

Finally, I solved this problem by myself.
use Set SELinux mode as permissive:
$ setenforce 0
$ docker exec -it cli bash
the detailed solution is below:
https://nanxiao.me/en/selinux-cause-permission-denied-issue-in-using-docker/
I have no idea why it happens, but I hope if it can help someone.

Use sudo when running the command, will solve the issue.

Related

Docker Tutorial Unclear: "Persisting our DB" and "Using Bind Mounts"

I have only started using Docker and was trying to follow the documentation on the official website... Everything was going smoothly until I got to this point.
In step 3:
Upon running the command, I get this error -> ls: cannot access 'C:/Program Files/Git/': No such file or directory.
I thought it was not that big of a deal so I went ahead and skipped to the following parts of the tutorial.
Then I came across the same error in this part:
I tried to locate the directory on my PC manually and found a remote git repository, but the commands still don't work for me. These were the commands that I have tried and their corresponding errors:
docker run -it ubuntu ls / - No such file or directory
cd /path/to/getting-started/app - No such file or directory
docker run -dp 3000:3000 ` -w /app -v "$(pwd):/app" ` node:12-alpine ` sh -c "yarn install && yarn run dev" - docker: Error response from daemon: the working directory 'C:/Program Files/Git/app' is invalid, it needs to be an absolute path.
See 'docker run --help'. (this error was after changing to the directory I manually searched on my PC)
I'm unsure if I have to set a PATH??? I don't think I have missed any of the steps provided in the earlier tutorials.
Thanks, guys! I was indeed using git bash on VSCode. I tried running it on my Windows terminal via ubuntu and now, everything's working fine. Thanks, Max, and Spears. Exactly what I was having issues with.
These comments helped me resolve the issue:
Maybe this is your problem github.com/docker-archive/toolbox/issues/673 –
Max
Sounds like you are using the git bash which comes packages with git scm for >windows. I strongly recommend to avoid this and switch to WSL2. The git bash >is NOT the kind of shell you are looking for when using docker due to missing >libs and nasty side effects which are mostly very hard to debug. - Spears

Run docker load inside RPM file

I'm trying to do an offline deployment of a docker image with RPM on CentOS.
My spec file is pretty simple :
Source1: myimage.tar.gz
...
%install
cp %{SOURCE1} ...
...
%post
docker load -i myimage.tar.gz
docker-compose up -d
docker image prune -af
I compress my image using docker save and gzip. Then, on another machine, I just load the image with docker and use docker-compose to run my service.
When executing the commands "docker load" and "docker-compose up", I got that error:
sudo: unable to execute /bin/docker: Permission denied
sudo: unable to execute /bin/docker-compose: Permission denied
sudo: unable to execute /bin/docker: Permission denied
My user is part of the docker group, I checked if the RPM file was executed using root, it is...
If I run the RPM on my dev machine, it works, if I execute the commands in a script that is not part of the RPM, it works...
Any ideas ?
Thanks in advance.
You're probably being blocked by SELinux. You can temporarily disable it to check with setenforce 0.
If that is the problem (it is; this is a comment turned into an answer), some possible solutions:
You might be able to use audit2allow to change the denials into new rules to import.
Maybe udica will help. I don't know enough about it to tell.
I tried the first solution and it worked ! grep rpm_script_t /var/log/audit/audit.log | audit2allow -m mypolicy > mypolicy.te
The problem came from the fact that the RPM scripts didn't have the access to the container_runtime_exec_t:file entrypoint that I suppose, allow it to run containers like docker.
Thanks a lot for the tip !

when using docker run i get mv: cannot stat but it works if i use /bin/bash

I need to move some files around and when i use the following command i get a connot stat error of move
docker run -v D:/PKS/potree/test/dist:/data1 -v D:/PKS/potree/test/tiles:/data2 -v D:/PKS/potree/test/tmp:/data3 oscar/mpc:v1 mv /data1/execution4/*/* /data1/tmp2
mv: cannot stat '/data1/execution4/*/*': No such file or directory
if i instead run a /bin/bash and manually type the same mv /data1/execution4/*/* /data1/tmp2 it works.
How can this be?
The shell expands your wildcards (or doesn’t, because they match nothing) before ever running docker. You’ll have to tell Docker to run a shell if you want wildcards expanded inside the container.
Thanks to Davis to put my in the right direction.
The answer is to do as following instead:
docker run oscar/mpc:v1 /bin/bash -c "mv /data1/execution22/*/* /data1/out1/"

Docker non-root access: Error loading config file:stat /home/wu/.docker/config.json

I finished the docker installation with non-root access, namely
1.define a docker user group
2.add my current user to the docker group
pass the test
docker run --rm hello-world
but when I start to provision my docker containers, somewhere in the procedure I got the error:
Error loading config file:stat /home/user/.docker/config.json:Permission Denied
seems to be docker is trying to access some resources but got denied
What is happening here? How could I fix this ?
thx
It may be that the .docker folder and the .docker/json.config file is not owned by the current user.
Try this:
sudo chown $USER:docker ~/.docker
sudo chown $USER:docker ~/.docker/config.json
sudo chmod g+rw ~/.docker/config.json
I've got the same error after upgrate from 1.4 to latest.
Fix: manually create .docker/config.json ( put empty json object there {} ) and set ownership like this :
-rw-r--r-- 1 myuser docker /home/myuser/.docker/config.json
Simply grant your current user to access the /.docker folder and your warning will get vanished in thin air.
Run this on your terminal:
sudo chown $USER:docker ~/.docker

Installing rbenv, permission denied

I am setting up my VPS to deploy my rails app, but permission denied error keeps happening on my server side. I had to reinstall perl and curl, and now I'm getting the following:
deployer#max:~$ rbenv bootstrap-ubuntu-12-04
bash: /usr/bin/python: permission denied
I tried reinstalling python but came up with no success. How should I solve it?
Update:
root#max:/home/deployer# cd /usr
root#max:/usr# cd bin
root#max:/usr/bin# cd python
bash: cd: python: not a directory
Does this mean python is not installed correctly?
Update:
deployer#max:~$ ls -l 'which python'
total 0
deployer#max:~$ python
bash: /usr/bin/python: permission denied
I thought this meant python was not installed correctly, so I computed the following
deployer#d:~$ su root
root#d:/home/deployer# apt-get install python
python package is already the latest version
So I failed to find the solution yet.
As it turned out it was a permissions issue, here are some general tips on how to debug a permission denied error when trying to execute a binary, python in this case:
ls -l `which python` - tries to retrieve full path and permissions, like -rwxr-xr-x 1 nobody nobody 9644 2012-12-02 13:15 /tmp/env/bin/python
Has to be run as a privileged user if permissions are 0000, for example.
sudo chmod 0755 /usr/bin/python usually helps.

Resources