I am trying to complete the instructions here: https://docs.docker.com/compose/aspnet-mssql-compose/. I am at the last stage:
$ docker-compose up
I see this error:
DotNetCore$ sudo docker-compose up
Starting dotnetcore_db_1 ... done
Starting dotnetcore_web_1 ... done
Attaching to dotnetcore_db_1, dotnetcore_web_1
web_1 | ./entrypoint.sh: line 2: $'\r': command not found
: invalid optionpoint.sh: line 3: set: -
web_1 | set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
web_1 | ./entrypoint.sh: line 5: $'\r': command not found
web_1 | ./entrypoint.sh: line 15: syntax error: unexpected end of file
dotnetcore_web_1 exited with code 2
I have spent all day trying to fix this simple error. Here is the entrypoint.sh:
#!/bin/bash
set -e
run_cmd="dotnet run --server.urls http://*:80"
until dotnet ef database update; do
>&2 echo "SQL Server is starting up"
sleep 1
done
>&2 echo "SQL Server is up - executing command"
exec $run_cmd
So far I have tried:
1) Open file using Notepad ++ and select Edit/EOL Conversion. Unix is greyed out. This method is descrbed here: https://askubuntu.com/questions/966488/how-do-i-fix-r-command-not-found-errors-running-bash-scripts-in-wsl
2) sudo dos2unix {filename}. This method is desecribed here: https://askubuntu.com/questions/966488/how-do-i-fix-r-command-not-found-errors-running-bash-scripts-in-wsl
How can I resolve this?
Your entrypoint script has windows linefeeds in it, they aren't valid on a Linux OS and are being parsed as commands to run. Correct that with your editor in the save menu, or use a utility like dos2unix to correct the files.
Once you have removed the linefeeds, you'll need to rebuild your image and then recreate a new container.
You could also set:
git config --global core.autocrlf input
from: https://github.com/docker/toolbox/issues/126
Related
My deploy stage failed,just that line
chmod og= $STAGE_ID_RSA
Got error
chmod og= $STAGE_ID_RSA
BusyBox v1.34.1 (2022-04-04 10:19:27 UTC) multi-call binary.
Usage: chmod [-Rcvf] MODE[,MODE]... FILE...
MODE is octal number (bit pattern sstrwxrwxrwx) or [ugoa]{+|-|=}[rwxXst]
-R Recurse
-c List changed files
-v Verbose
-f Hide errors
ERROR: Job failed: exit code 1
I read this
Gitlab CI/CD pipeline error
but I do not have .ssh on Gitlab server(located on other server).
How to change file content permission?
check if "STAGE_ID_RSA" is saved as "file" not "variable" on the gitlab's variable configuration page.
Im trying to run my .sh scipt status.sh via a telegram message:
Ubuntu 20.04.1 LTS server
Telegram-cli with a lua script to action status.sh script
when i send the message "status" to my server via telegram it actions the status.sh script, in this script i have a bunch of stuff that gathers info for me and sends it back to telegram so i can see what the status of my server is, however (i recently did a fresh install of the server) for some reason if the script has a line of code starting with sudo i get:
line 38: /usr/bin/sudo: Permission denied
if i run the script from the command line ./status.sh it runs without any problem!? so im thinking its because it is being called from telegram or lua!?
example of code that generates the error: sudo ifconfig enp0s25 >> file
on the other hand this line works without a problem:
sudo echo Time: $(date +"%H:%M:%S") > file
/usr/bin has 0755 permission set
sudo has 4755 permission set
The following command
sudo ifconfig enp0s25 >> file
would not work if file requires root privilege to be modified.
sudo affects ifconfig but not the redirection.
To fix it:
sudo sh -c 'ifconfig enp0s25 >> file'
As mentioned in Egor Skriptunoff's answer, sudo only affects the command being run with sudo, and not the redirect.
Perhaps nothing is being written to file in your case because ifconfig is writing the output you are interested in to stderr instead of to stdout.
If you want to append both stdout and stderr to file as root, use this command:
sudo sh -c 'ifconfig enp0s25 >> file 2>&1'
Here, sh is invoked via sudo so that the redirect to file will be done as root.
Without the 2>&1, only ifconfig's stdout will be appended to file. The 2>&1 tells the shell to redirect stderr to stdout.
If file can be written to without root, this may simplify to
sudo ifconfig enp0s25 >> file 2>&1
Crontab task doesn't work when I edit crontab by vim instead of "crontab -e" on docker container ubuntu18.04
step 1:
Use docker run a container, the image is ubuntu18.04 os.
step 2:
vim /var/spool/cron/crontabs/root
and Write content to root file as following:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/1 * * * * . /etc/profile; /bin/sh /test_cron/xx.sh 2>&1
step 3:
cd /
mkdir test_cron
cd test_cron
step 4:
Edit xx.sh in /test_cron/xx.sh, the content as following:
echo "cron job has start" >> /test_cron/run.log
step 5:
service cron restart
step 6:
There is no run.log in /test_cron/, that’s to say, the crontab task doesn't work. But if I using "crontab -e" to open the /var/spool/cron/crontabs/root file and don't make anything modify. Just open and close the /var/spool/cron/crontabs/root, I can see the run.log file in /test_cron/, amazing, the crontab task worked. Could you tell me the reason?
Few points,
The corntab -e makes sure certain formatting and error tracking to an extent.
crontab file should contain one empty line at the end.
There are certain permission to set to the crontab chmod 600
After completing these I could see the manual entry was working. However it is not recommended to directly edit the crontab file and the best practice is to use crontab -e
EDIT: Actually emptyline should be corrected as newline character or % as per the man page
The "sixth" field (the rest of the line) specifies the command to be
run. The entire command portion of the line, up to a newline or %
character, will be executed by /bin/sh or by the shell specified in
the SHELL variable of the cronfile. Percent-signs (%) in the command,
unless escaped with backslash (), will be changed into newline
characters, and all data after the first % will be sent to the command
as standard input.
I'm running a docker container on heroku, but I can't seem to understand how it works.
Locally I'm able to run a command docker run imageName ls -al, but on heroku: heroku run "ls -al" it returns ./entrypoint.sh: line 34: exec: ls -al: not found. Although when I run heroku run ls without arguments, it works as expected. (as another experiment I've run heroku run bash and then ./entrypoint.sh ls -al that also works).
What's happening here?
Comments updates:
Damien MATHIEU: the image I try to run is this https://github.com/jshimko/meteor-launchpad - and my docker file is:
FROM jshimko/meteor-launchpad:latest
CMD ["node", "main.js"]
Edit-2 - 28-Oct-2017
Latest update from Heroku
We've triaged this, and we're definitely not implementing Docker-compatible behaviour here. Thanks for catching this - we'll get it fixed.
Original answer
Your error is quite clear from below itself
./entrypoint.sh: line 34: exec: ls -al: not found
You are passing ls -al as one string parameter. You should try below
heroku run -- ls -al
Edit-1
So I created a simple Dockerfile to test the issue.
FROM alpine
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["tail", "-f", "/dev/null"]
And the entrypoint.sh
#!/bin/sh
echo "You passed $# arguments"
for var in "$#"
do
echo "$var"
done
exec "$#"
When I build and run the container locally I get the output as
$ docker run -it 5e866a76fd25
You passed 3 arguments
tail
-f
/dev/null
When I push the app to Heroku I get below output on logs
2017-10-21T19:11:11.873567+00:00 app[api]: Deployed web (xxxxx) by user xxx#yyy.com
2017-10-21T19:11:14.235819+00:00 heroku[web.1]: Starting process with command `tail -f /dev/null`
2017-10-21T19:11:16.593724+00:00 heroku[web.1]: Process exited with status 127
2017-10-21T19:11:16.447960+00:00 app[web.1]: You passed 1 arguments
2017-10-21T19:11:16.447976+00:00 app[web.1]: tail -f /dev/null
This is completely wrong, as the CMD is being sent quoted as a single argument instead of the 3 arguments. I have opened a ticket for the same with heroku team, hopefully they will reply before Tue
I'm also running into this issue. As a temporary workaround, I've put my original CMD into a separate script file, and now calling that script file in CMD.
Here's my original Dockerfile:
...
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]
Here's my new Dockerfile:
...
RUN chmod +x PATH_TO_START_SCRIPT/start.sh
CMD ["./start.sh"]
And my start.sh script (starting a Rails app):
#!/bin/bash
set -e
echo "Starting Puma server..."
bundle exec puma -C config/puma.rb
This question already has answers here:
Why would a correct shell script give a wrapped/truncated/corrupted error message? [duplicate]
(1 answer)
Syntax error : end of file unexpected (expecting "fi")
(4 answers)
Closed 2 years ago.
I am running the startup.sh script from Dockerfile and I get the error below when I run the docker container:
docker run -p 5308:5308 activity-logger
: not found line 2:
: not found line 5:
startup.sh: line 13: syntax error: unexpected end of file (expecting "then")
If I try to run sh startup.sh from my command line it seems to work well.
Any ideas?
startup.sh
#!/bin/sh
export env_file=`echo microservice-configuration/$LS_ENVIRONMENT.environment.properties`
export startup_command="npm run start:dist"
if [ -f $env_file ]; then
echo "Using environment specific configuration file $env_file"
env $(cat $env_file | xargs) $startup_command
else
echo "There is no environment specific configuration file $env_file"
$startup_command
fi
Dockerfile
FROM node:6.9.4-alpine
# Create app directory
RUN mkdir -p /opt/app
WORKDIR /opt/app
COPY . /opt/app
RUN npm install -g yarn
RUN yarn
RUN yarn build
# This is not working very well - the dependencies cannot be installed afterwards
# RUN yarn --production
ENV NODE_ENV production
EXPOSE 5308
CMD ["/bin/sh", "startup.sh"]
: not found line 2:
That's pointing to something screwy with the white space in this file. The most likely cause is editing the script on windows and getting the wrong line feeds. Stop using whatever editor you were using and fix the script with a better editor or a utility like dos2unix.