shipping-docker / php-app

A containerized Laravel application
278 stars 73 forks source link

first step in course now working on Windows 7: docker-compose returned -1 #19

Open cmosguy opened 7 years ago

cmosguy commented 7 years ago

Hey @fideloper ,

I am trying to go through your course. I have Windows 7 and have all the latest downloads for the docker toolbox.

After I pull your repo, I am struggling with the first step. It does not work when I do a docker-composer:

$ cd php-app/

$ docker-compose up -d
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "compose\cli\main.py", line 65, in main
  File "compose\cli\main.py", line 117, in perform_command
  File "compose\cli\main.py", line 849, in up
  File "compose\project.py", line 372, in up
  File "compose\project.py", line 539, in warn_for_swarm_mode
  File "site-packages\docker\api\daemon.py", line 33, in info
  File "site-packages\docker\utils\decorators.py", line 47, in inner
  File "site-packages\docker\client.py", line 139, in _get
  File "site-packages\requests\sessions.py", line 488, in get
  File "site-packages\requests\sessions.py", line 475, in request
  File "site-packages\requests\sessions.py", line 596, in send
  File "site-packages\requests\adapters.py", line 423, in send
  File "site-packages\requests\packages\urllib3\connectionpool.py", line 595, in urlopen
  File "site-packages\requests\packages\urllib3\connectionpool.py", line 363, in _make_request
  File "httplib.py", line 1057, in request
  File "httplib.py", line 1097, in _send_request
  File "httplib.py", line 1053, in endheaders
  File "httplib.py", line 897, in _send_output
  File "httplib.py", line 859, in send
  File "site-packages\docker\transport\npipeconn.py", line 31, in connect
  File "site-packages\docker\transport\npipesocket.py", line 22, in wrapped
  File "site-packages\docker\transport\npipesocket.py", line 49, in connect
pywintypes.error: (2, 'WaitNamedPipe', 'The system cannot find the file specified.')
docker-compose returned -1

I don't understand what is wrong here, and the only thing I can find when searching around is with regards to Windows 7 has issueswith really long path lengths. However, I do not understand this as the directory I am working in is /c/w/php-app so I can not see how this would effect things.

Anyways, would really like your ideas here.

fideloper commented 7 years ago

Hi!

Looks like it is saying it can't find a file on the very bottom of that stack trace (whose error message I think may be the important one).

This issue opened recently might be related - https://github.com/docker/for-win/issues/316 On Sat, Dec 17, 2016 at 12:25 Adam Klein notifications@github.com wrote:

Hey @fideloper https://github.com/fideloper ,

I am trying to go through your course. I have Windows 7 and have all the latest downloads for the docker toolbox.

After I pull your repo, I am struggling with the first step. It does not work when I do a docker-composer:

$ cd php-app/

$ docker-compose up -d Traceback (most recent call last): File "", line 3, in File "compose\cli\main.py", line 65, in main File "compose\cli\main.py", line 117, in perform_command File "compose\cli\main.py", line 849, in up File "compose\project.py", line 372, in up File "compose\project.py", line 539, in warn_for_swarm_mode File "site-packages\docker\api\daemon.py", line 33, in info File "site-packages\docker\utils\decorators.py", line 47, in inner File "site-packages\docker\client.py", line 139, in _get File "site-packages\requests\sessions.py", line 488, in get File "site-packages\requests\sessions.py", line 475, in request File "site-packages\requests\sessions.py", line 596, in send File "site-packages\requests\adapters.py", line 423, in send File "site-packages\requests\packages\urllib3\connectionpool.py", line 595, in urlopen File "site-packages\requests\packages\urllib3\connectionpool.py", line 363, in _make_request File "httplib.py", line 1057, in request File "httplib.py", line 1097, in _send_request File "httplib.py", line 1053, in endheaders File "httplib.py", line 897, in _send_output File "httplib.py", line 859, in send File "site-packages\docker\transport\npipeconn.py", line 31, in connect File "site-packages\docker\transport\npipesocket.py", line 22, in wrapped File "site-packages\docker\transport\npipesocket.py", line 49, in connect pywintypes.error: (2, 'WaitNamedPipe', 'The system cannot find the file specified.') docker-compose returned -1

I don't understand what is wrong here, and the only thing I can find when searching around is with regards to Windows 7 has issueswith really long path lengths. However, I do not understand this as the directory I am working in is /c/w/php-app so I can not see how this would effect things.

Anyways, would really like your ideas here.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shipping-docker/php-app/issues/19, or mute the thread https://github.com/notifications/unsubscribe-auth/AAch071dmSaY7kRBOkYkVu0bXA-70udWks5rJCkngaJpZM4LP8t1 .

cmosguy commented 7 years ago

Hey @fideloper ,

Well, it looks like I had this setup in my path:

C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python35-32\Scripts\ C:\Users\MYUSERNAME\AppData\Local\Programs\Python\Python35-32\

I don't know how that was set or what installed that, perhaps docker toolbox? Not sure, but once I changed the path to be pointed to python2.7 in my windows environment, then everything started working correctly and it pulled all the images that I needed for this.

Thanks for your prompt response.

Adam

talaviss commented 7 years ago

this does not solve the problem on windows 7

pablo09 commented 7 years ago

Make sure that you've built entire project and then instead of Windows Commandline use Docker CLI (do not confuse with normal Windows Powershell!)

sobelfallcayor commented 7 years ago

Run docker-compose with Docker Quickstart Terminal. It will solve your error

vipul-rav commented 7 years ago

check your local machine/server docker is running

ranneyd commented 7 years ago

I'm using docker-toolbox in Windows and ran into this problem. I solved it by making sure the environment variables were properly set.

My docker-machine is called toolbox. I made sure it was running and I ran docker-machine env toolbox . It gave me a thing, the last line of which was a comment that contained @FOR /f "tokens=*" %i IN ('docker-machine env toolbox') DO @%i. I ran that and it set all the variables I needed. Then it just worked. Hope that helps

sobelfallcayor commented 7 years ago

Yes @ranneyd it fixe it. Thanks

TheGeniesis commented 7 years ago

My solution based on @ranneyd answer (I didn't know how my docker-machine is called): In Docker Quickstart Terminal I ran docker-machine env, it gave me:

export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:\Users\TheGeniesis\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)

I ran eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env) That's it!

gitowiec commented 7 years ago

I tried to run @TheGeniesis solution in Git shell for Windows for project https://github.com/andreaskoch/dockerized-magento but all I got was errors:

Gitowiec@INSPIRON42 /c/workspace/magento/dockerized-magento (master)
$ which docker-machine
/c/Docker Toolbox/docker-machine

Gitowiec@INSPIRON42 /c/workspace/magento/dockerized-magento (master)
$ eval $("/c/Docker Toolbox/docker-machine.exe" env)
sh.exe": syntax error near unexpected token `('

Gitowiec@INSPIRON42 /c/workspace/magento/dockerized-magento (master)
$ eval $("c:\Docker Toolbox\docker-machine.exe" env)
sh.exe": syntax error near unexpected token `('

Gitowiec@INSPIRON42 /c/workspace/magento/dockerized-magento (master)
$ bash
bash-3.1$ eval $("/c/Docker Toolbox/docker-machine.exe" env)
bash: syntax error near unexpected token `('

How to run this command under Git shell?

gitowiec commented 7 years ago

Ok, I managed to get over this problem. I used shell available under the "Docker Quickstart Terminal" shortcut icon. Then I changed path in C:\Docker Toolbox\start.sh (line 8 ) from export PATH="/c/Program Files/Docker Toolbox:$PATH" to export PATH="/c/Docker Toolbox:$PATH" (obvious, my installation place was root of C: drive). Then in magento script I applied this: https://github.com/andreaskoch/dockerized-magento/pull/40/files and changed all "DOCKER=which docker" to "DOCKER=which docker.exe"

sobelfallcayor commented 7 years ago

Open Terminal Gil shell : Un docker-machine env than copy line eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env) than run it :

eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)

gitowiec commented 7 years ago

@fallphenix don't You see that I tried this? Take a closer look at my first post in this thread. I tried it 3 times with slightly differences, all I got was error syntax error near unexpected token '('

stevemoreau commented 7 years ago

In case it can help somebody, I think I may have met the same trap :) From a standard mintty terminal (cygwin), I got CMD commands instead of UNIX ones:

[smoreau@xny-wst-001: /cygdrive/d/project/etc/docker] (master % u=)$ docker-machine env
You can further specify your shell with either 'cmd' or 'powershell' with the --shell flag.

SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.100:2376
SET DOCKER_CERT_PATH=C:\Users\smoreau\.docker\machine\machines\default
SET DOCKER_MACHINE_NAME=default
SET COMPOSE_CONVERT_WINDOWS_PATHS=true
REM Run this command to configure your shell:
REM     @FOR /f "tokens=*" %i IN ('"C:\Program Files\Docker Toolbox\docker-machine.exe" env') DO @%i

In this case, you may consider trying this one: $(docker-machine env | sed -n 's/SET /export /gp')

Serhiy-Shekhovtsov commented 7 years ago

Few helping notes: if you run it from windows command prompt or batch script, your command is: @FOR /f "tokens=*" %i IN ('docker-machine env MACHINE_NAME') DO @%i where MACHINE_NAME is your machine's name

if you run it from bash script, your command is: eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env MACHINE_NAME --shell=bash)

important note I hoped that running this command completely solves the issue, but it's not like this. It will set variables for current session. If you close the terminal you have to run the same command again. So, best solution here is to put this as a first line of your .bat or .sh file and always start your terminal by running that file.

truthadjustr commented 6 years ago

The way I solved it is I went inside the docker host, installed docker-compose there, copy docker docker-compose.yml file there, and run the compose there.

The windows DOS, cygwin, powershell, whatever is causing all these confusions.

Herbis commented 6 years ago

For anyone using Git Bash, for a more permanent solution, you can modify the file: C:\Program Files\Git\etc\profile and at the very bottom add line: eval $(docker-machine env) So when you start a new session, docker commands should work from the get-go.