Can't get Nginx to run under Docker environment on Windows for unknown reason

1.8k Views Asked by At

So, the last week or so I've been struggling trying to get my nginx server to run off of Docker/Laradock. The weird thing is that it worked when I was running it off C:/, but after being told by work that I had to encrypt my disk, I downloaded VeraCrypt and made an encrypted drive Y:/ and copied my vhosts folder into there.

After a lot of struggles trying to even get the laradock_nginx_1 to attach, I followed this guide, as I thought maybe Docker Toolbox didn't have access to the Y:/ drive. This seemed to work, but I still get a weird error when trying to get nginx up and running:

Y:\vhosts\laradock>docker-compose up nginx WARNING: The PHP_FPM_INSTALL_TOKENIZER variable is not set. Defaulting to a blank string. laradock_workspace_1 is up-to-date Starting laradock_docker-in-docker_1 ... done Starting laradock_php-fpm_1 ... done Starting laradock_nginx_1 ... done Attaching to laradock_nginx_1 nginx_1 | /opt/startup.sh: line 2: $'\r': command not found nginx_1 | /opt/startup.sh: line 10: syntax error: unexpected end of file laradock_nginx_1 exited with code 2

Read somewhere else that the \r was simply the line ending of Windows. I tried to cd into /opt/startup.sh, but it didn't seem to exist. I found out that there was another startup.sh inside laradock/nginx/, I ssh'ed into the Docker VM and saw that every line ended with ^M, which I suspect might've been \r. I removed those, but nothing really changed, still got the same problem.

While in ssh, I also did a hexdump of the startup bash file using hexdump startup.sh | grep 0d0a, but nothing came up. I'm at a loss for solutions, and not really sure what else I can try to do. Please note that Docker for Windows or BitLocker is out of the question since I only have Windows 10 Home.

What could I try to remedy this problem? Is this a known problem?

1

There are 1 best solutions below

1
On

You can try to convert laradock\nginx\startup.sh file's windows style line endings to linux style line endings, i.e. with Notepad++ ( Edit > EOL Conversion > Unix (LF) ).

Then try to start nginx container with rebuild option:

docker-compose up --build nginx