0

When I run docker-compose, I get an error:

php_1       | /usr/local/bin/docker-entrypoint.sh: line 2: $'\r': command not found
php_1       | Do not run Composer as root/super user! See https://getcomposer.org/root for details
php_1       |
php_1       |
php_1       |   [Symfony\Component\Console\Exception\CommandNotFoundException]
" is not defined.
php_1       |
php_1       |   Did you mean this?
php_1       |       update
php_1       |
php_1       |
php_1       | /usr/local/bin/docker-entrypoint.sh: line 4: $'\r': command not found
: not found | /usr/local/bin/docker-entrypoint.sh: line 5: exec: php-fpm

I tried to restart the docker, delete the containers and restart, but nothing helps

docker-entrypoint.sh code:

#!/usr/bin/env bash

composer update

exec "$@"

I used to use ubuntu, now I have installed windows and now I get this error. Please tell me how I can solve this problem, I have spent more than 3 hours and no result (

4
  • Can you check the content of the docker-entrypoint.sh script? This looks like a syntax problem in there. Or possibly it uses an environment variable that is not set to the correct value. Commented Apr 2, 2019 at 7:34
  • I'll add one second Commented Apr 2, 2019 at 7:36
  • I added, you can watch Commented Apr 2, 2019 at 7:40
  • Thanks, yes indeed Windows moved the line Commented Apr 2, 2019 at 8:10

2 Answers 2

1

The error "/usr/local/bin/docker-entrypoint.sh: line 2: $'\r': command not found", together with the content of the docker-entrypoint.sh script (which contains only a blank line at 2) indicates that the line endings are corrupted.

You should make sure that the files used by the container have UNIX line endings (\n) rather than Windows line endings (\r\n).

Sign up to request clarification or add additional context in comments.

Comments

0

Make sure to run dos2unix on script file whenever anyone edit anything on any kind of editor on Windows to convert the line endings, (recommended) remove dos2unix from the machine.

In your case:

# add this line after FROM line
RUN apt-get update && apt-get install -y dos2unix
RUN dos2unix /usr/local/bin/docker-entrypoint.sh && apt-get --purge remove -y dos2unix
# --> continue your ./docker/php/Dockerfile content

Check my answer https://stackoverflow.com/a/55470819/7596401

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.