I have two commands to execute in release phase and as per this tutorial (https://devcenter.heroku.com/articles/release-phase), I have included them in a shell script named release.sh (located in the root of my Django project).
#!/bin/bash
python manage.py migrate
python manage.py compress
In my Procfile, I added the script thus, as described in the article.
release: ./release.sh
web: gunicorn myapp.wsgi --log-file -
But during release I get the following error.
/bin/sh: 1: ./release.sh: not found
Then the release fails.
I don't know if the problem is with the path in Procfile (I also tried bash $PWD/releash.sh) or the file not being available at the time it is called. Any help would be appreciated.
EDIT:
My release.sh was in a subfolder and that's why it wasn't found, but now I'm getting permission denied.
/bin/sh: 1: ./release.sh: Permission denied
This worked
chmod u+x release.sh && ./release.sh
So Procfile becomes
release: chmod u+x release.sh && ./release.sh
web: gunicorn myapp.wsgi --log-file -
For this to work, release.sh must be executable
Locally, you could run chmod a+x release.sh. But you would not want to do that on heroku, so instead you can change the Profile to have this:
release: bash release.sh
web: gunicorn myapp.wsgi --log-file -
Related
I'm using Jenkins to run the CI. I'm using the docker image mingc/android-build-box to run a fastlane lane (dokka) in a container.
If I follow the guidelines suggested here and I run:
docker run --rm -v `pwd`:/project mingc/android-build-box bash -c 'cd /project; bundle exec fastlane dokka'
the operation succeeds but all the generated files are owned by root. This breaks the CI because I can't delete them when they are not necessary anynmore.
I tried to pass the CI user:
docker run --rm --user $(id -u):$(id -g) -v `pwd`:/project mingc/android-build-box bash -c "cd /project; bundle install --deployment; bundle exec fastlane dokka"
I get the error:
/ is not writable.
Bundler will use `/tmp/bundler20200511-6-m21qkb6' as your home directory temporarily.
bundler: failed to load command: fastlane (/usr/local/bin/fastlane)
Bundler::GemNotFound: Could not find aws-eventstream-1.1.0 in any of the sources
So I tried to call bundle install --deployment before bundle exec and now I get the error:
fileutils.rb:232:in `mkdir': [!] Permission denied # dir_s_mkdir - /.fastlane (Errno::EACCES)
I googled the error and I've found many reports but none of them contains a useful answer and anyway, this wouldn't be ideal because the docker image already has the fastlane gem installed and it would be good to be able to use it without having to reinstall it.
Another solution would be to let the container run with root as user and then delete the files after having used them. This solution is not ideal either because I would have to remember to delete every file created but the container.
If you're running this in Jenkins, its standard Docker support handles the mounts, permissions, etc. for you. In scripted pipeline code, it should be enough to do
docker.inside('mingc/android-build-box') {
sh 'bundle exec fastlane dokka'
}
Jenkins will mount the WORKDIR into the container (on an identical path), run as the same user ID, keep the same working directory, and so on. You can see in its logs the (rather long) docker run command it uses.
I followed article
https://devcenter.heroku.com/articles/release-phase#specifying-release-phase-tasks
to configure to run a script during release step.
unfortunately the release results in the following error (Release Log):
/bin/sh: 1: ./release-tasks.sh: Permission denied
how can I fix this?
my Procfile:
release: ./release-tasks.sh
web: gunicorn ph.wsgi --preload --log-file -
release-tasks.sh (simplified):
#!/bin/bash
python manage.py migrate --noinput
Git ignores most file permissions, but it does track the executable bit. Make your script executable and check it in, e.g.
chmod +x release-tasks.sh
git add release-tasks.sh
git commit -m "Make release-tasks.sh executable"
Then deploy as normal.
On Windows, you won't have chmod. Use the --chmod option to git add instead:
git add --chmod=+x release-tasks.sh
git commit -m "Make release-tasks.sh executable"
I have my own script in /etc/profile.d/myscript.sh (mounted from the host) prepared in the container, but it fails to execute when docker run
$ docker run -it -v /etc/profile.d/myscript.sh:/etc/profile.d/myscript.sh centos7 myscript arg1
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"myscript\": executable file not found in $PATH": unknown.
if docker run without any command, then I directly attach into the container, the script works.
The script is there under /etc/profile.d/, and I am able to run myscript inside the container
[root#c5f121d37ca5 /]# myscript
Usage:
myscript [arg1] [arg2]
...
[root#c5f121d37ca5 /]#
[root#c5f121d37ca5 /]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
I have no clue why my script is not executable with docker run.
my Dockerfile for the image is just basic things which does yum update, install some pkg.
Appreciate if someone please shed me some light on how to make myscript executable at docker run? or anything i need to work on the dockerfile?
I also added the path of the script in Dockerfile and re-ran but still got the same error.
ENV PATH=$PATH:/etc/profile.d/
I checked the /etc/profile.d/ is in the PATH inside the container.
$ docker run centos7 env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/profile.d/
I'm trying to dockerize my node.js app. When the container is built I want it to run a git clone and then start the node server. Therefore I put these operations in a .sh script. And run the script as a single command in the ENTRYPOINT:
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y build-essential libssl-dev gcc curl npm git
#install gcc 4.9
RUN apt-get install -y software-properties-common python-software-properties
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test
RUN apt-get update
RUN apt-get install -y libstdc++-4.9-dev
#install newst nodejs
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN apt-get install -y nodejs
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ADD package.json /usr/src/app/
RUN npm install
ADD docker-entrypoint.sh /usr/src/app/
EXPOSE 8080
ENTRYPOINT ["/usr/src/app/docker-entrypoint.sh"]
My docker-entrypoint.sh looks like this:
git clone git#<repo>.git
git add remote upstream git#<upstream_repo>.git
/usr/bin/node server.js
After building this image and run:
docker run --env NODE_ENV=development -p 8080:8080 -t -i <image>
I'm getting:
docker: Error response from daemon: oci runtime error: exec: "/usr/src/app/docker-entrypoint.sh": permission denied.
I shell into the container and the permission of docker-entrypoint.sh is:
-rw-r--r-- 1 root root 292 Aug 10 18:41 docker-entrypoint.sh
three questions:
Does my bash script have wrong syntax?
How do I change the permission of a bash file before adding it into an image?
What's the best way to run multiple git commands in entrypoint without using a bash script?
Thanks.
"Permission denied" prevents your script from being invoked at all. Thus, the only syntax that could be possibly pertinent is that of the first line (the "shebang"), which should look like #!/usr/bin/env bash, or #!/bin/bash, or similar depending on your target's filesystem layout.
Most likely the filesystem permissions not being set to allow execute. It's also possible that the shebang references something that isn't executable, but this is far less likely.
Mooted by the ease of repairing the prior issues.
The simple reading of
docker: Error response from daemon: oci runtime error: exec: "/usr/src/app/docker-entrypoint.sh": permission denied.
...is that the script isn't marked executable.
RUN ["chmod", "+x", "/usr/src/app/docker-entrypoint.sh"]
will address this within the container. Alternately, you can ensure that the local copy referenced by the Dockerfile is executable, and then use COPY (which is explicitly documented to retain metadata).
An executable file needs to have permissions for execute set before you can execute it.
In your machine where you are building the docker image (not inside the docker image itself) try running:
ls -la path/to/directory
The first column of the output for your executable (in this case docker-entrypoint.sh) should have the executable bits set something like:
-rwxrwxr-x
If not then try:
chmod +x docker-entrypoint.sh
and then build your docker image again.
Docker uses it's own file system but it copies everything over (including permissions bits) from the source directories.
I faced same issue & it resolved by
ENTRYPOINT ["sh", "/docker-entrypoint.sh"]
For the Dockerfile in the original question it should be like:
ENTRYPOINT ["sh", "/usr/src/app/docker-entrypoint.sh"]
The problem is due to original file not having execute permission.
Check original file has permission.
run ls -al
If result get -rw-r--r-- ,
run
chmod +x docker-entrypoint.sh
before docker build!
Remove Dot [.]
This problem take with me more than 3 hours finally, I just tried the problem was in removing dot from the end just.
problem was
docker run -p 3000:80 --rm --name test-con test-app .
/usr/local/bin/docker-entrypoint.sh: 8: exec: .: Permission denied
just remove dot from the end of your command line :
docker run -p 3000:80 --rm --name test-con test-app
Grant execution rights to the file docker-entrypoint.sh
sudo chmod 775 docker-entrypoint.sh
This is a bit stupid maybe but the error message I got was Permission denied and it sent me spiralling down in a very wrong direction to attempt to solve it. (Here for example)
I haven't even added any bash script myself, I think one is added by nodejs image which I use.
FROM node:14.9.0
I was wrongly running to expose/connect the port on my local:
docker run -p 80:80 [name] . # this is wrong!
which gives
/usr/local/bin/docker-entrypoint.sh: 8: exec: .: Permission denied
But you shouldn't even have a dot in the end, it was added to documentation of another projects docker image by misstake. You should simply run:
docker run -p 80:80 [name]
I like Docker a lot but it's sad it has so many gotchas like this and not always very clear error messages...
This is an old question asked two years prior to my answer, I am going to post what worked for me anyways.
In my working directory I have two files: Dockerfile & provision.sh
Dockerfile:
FROM centos:6.8
# put the script in the /root directory of the container
COPY provision.sh /root
# execute the script inside the container
RUN /root/provision.sh
EXPOSE 80
# Default command
CMD ["/bin/bash"]
provision.sh:
#!/usr/bin/env bash
yum upgrade
I was able to make the file in the docker container executable by setting the file outside the container as executable chmod 700 provision.sh then running docker build . .
If you do not use DockerFile, you can simply add permission as command line argument of the bash:
docker run -t <image> /bin/bash -c "chmod +x /usr/src/app/docker-entrypoint.sh; /usr/src/app/docker-entrypoint.sh"
If you still get Permission denied errors when you try to run your script in the docker's entrypoint, just try DO NOT use the shell form of the entrypoint:
Instead of:
ENTRYPOINT ./bin/watcher write ENTRYPOINT ["./bin/watcher"]:
https://docs.docker.com/engine/reference/builder/#entrypoint
I am attempting to run gradlew from my command line, but am constantly facing the following error.
Brendas-MacBook-Pro:appx_android brendalogy$ ./gradlew compileDebug --stacktrace
-bash: ./gradlew: Permission denied
I am already running this command from my project directory. Need to run this command as I am facing the same (nondescriptive) error on Android Studio 0.2.x as encountered here: Android studio and gradle build error
Am I doing something wrong and how do I get around this?
Try to set the execution flag on your gradlew file:
chmod +x gradlew
Could also be fixed with
git update-index --chmod=+x gradlew
You need to update the execution permission for gradlew
Locally: chmod +x gradlew
Git:
git update-index --chmod=+x gradlew
git add .
git commit -m "Changing permission of gradlew"
git push
You should see:
mode change 100644 => 100755 gradlew
You could use "bash" before command:
bash ./gradlew compileDebug --stacktrace
Jenkins > Project Dashboard > (select gradle project) Configure > Build
x Use Gradle Wrapper
Make gradlew executable x
Just type this command in Android Studio Terminal (Or your Linux/Mac Terminal)
chmod +x gradlew
and try to :
./gradlew assembleDebug
on android folder cmd run
chmod +x gradlew
and run
./gradlew clean
and root project run
react-native run-android
git update-index --chmod=+x gradlew
This command works better especially on non-unix system.
With this step set permission to gradlew
steps {
echo 'Compile project'
sh "chmod +x gradlew"
sh "./gradlew clean build --no-daemon"
}
This issue occur when you migrate your android project build in windows to any unix operating system (Linux). So you need to run the below command in your project directory to convert dos Line Break to Unix Line Break.
find . -type f -print0 | xargs -0 dos2unix
If you dont have dos2unix installed. Install it using
In CentOs/Fedora
yum install dos2unix
In Ubuntu and other distributions
sudo apt install dos2unix
if it doesn't work after chmod'ing make sure you aren't trying to execute it inside the /tmp directory.
Try below command:
chmod +x gradlew && ./gradlew compileDebug --stacktrace
I got the same error trying to execute flutter run on a mac. Apparently, in your flutter project, there is a file android/gradlew that is expected to be executable (and it wasn't). So in my case,
chmod a+rx android/gradlew
i used this command and execute the project
Sometimes the error is just a typo, using gradle instead of gradlew wrapper.
For Linux Only
View > Tool Windows > Terminal
before
./gradlew.bat tasks
after
./gradlew tasks
eg
./gradlew dokkaHtml
For Windows users facing this issue in android studio, change your terminal to cmd from Windows PowerShell
past it in your terminal:
chmod 755 android/gradlew.
If you face this error in Github actions, you need to add this step before ./gradlew assembleDebug:
- name: Make gradlew executable
run: chmod +x ./gradlew