hackoregon / backend-examplar-2018

an example dockerized geo-aware django backend
MIT License
4 stars 5 forks source link

Problems on Windows 10 Home #50

Open znmeb opened 6 years ago

znmeb commented 6 years ago

@mxmoss has run into an error starting the API container on a Windows 10 Home / Docker Toolbox configuration. @nam20485 and I have been able to reproduce it with Docker for Windows from WSL Ubuntu, but that's not a supported Docker use case. I can reproduce it on this repo with the sample "dead_songs" dataset, and I'm going to attempt to troubleshoot it with Docker Machine on Linux,

Meanwhile, on Docker for Windows on Windows 10 Pro, both repos work if you do the build and start from PowerShell.

bhgrant8 commented 6 years ago

thank you for documenting, let us know if further help is needed.

znmeb commented 6 years ago

I've got some clues finally. Docker Toolbox (what @mxmoss and other Windows < Window 10 Pro users have) uses Docker Machine to create and manage the VirtualBox machines on Windows. It turns out that all of this magic also works on Linux hosts, but nobody uses it because Docker is native for Linux - no virtual machine required.

So I installed Docker Machine and VirtualBox on Linux and created a Docker machine. I was able to duplicate the error @mxmoss got. But several hours of searching and experimentation didn't come up with a solution.

This is the error message:

$ bin/start.sh -d
Creating network "backend-examplar-2018_default" with the default driver
Creating backend-examplar-2018_db_development_1 ... done
Creating backend-examplar-2018_api_development_1 ... error

ERROR: for backend-examplar-2018_api_development_1  Cannot start service api_development: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./bin/development-docker-entrypoint.sh\": stat ./bin/development-docker-entrypoint.sh: no such file or directory": unknown

ERROR: for api_development  Cannot start service api_development: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"./bin/development-docker-entrypoint.sh\": stat ./bin/development-docker-entrypoint.sh: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.

The problem is that the API container is supposed to mount "." - the repository - into /code/ in the container. It isn't getting mounted and there's no error message on the mount failure. As is typical with Docker products, you can find postings about the issue and statements that it's fixed, but it isn't fixed. I tried numerous variants of the volumes entry in development-docker-compose.yml and couldn't find anything that worked.

An even simpler test:

$ docker run -it --rm -v /d/Projects/backend-examplar-2018:/code api_development /bin/bash
root@98901fa5bdd6:/code# ls -al
total 4
drwxr-xr-x  2 root root   40 Apr 28 19:13 .
drwxr-xr-x 77 root root 4096 Apr 28 19:19 ..
root@98901fa5bdd6:/code# 

Even an explicit mount of an absolute host path using a docker run fails silently. This is probably an issue in the Docker Machine VirtualBox driver - the virtual machine probably isn't configured correctly to share arbitrary host files.

There are two use cases for Docker Machine:

  1. This one - supporting Docker on non-Linux hosts via VirtualBox, which is deprecated in favor of Docker for Windows and Docker for MacOS, and
  2. Deploying to the cloud, which pretty much everyone does some other way, like native AWS tools or Kubernetes. ;-)

So I'm not optimistic about Docker coming up with a solution. There are 778 issues open on Docker Machine (https://github.com/docker/machine/issues), some of which look relevant but date back over a year.

nam20485 commented 6 years ago

So is the fix for this issue to change the "shebang" lines in the scripts from #!bin/bash to #!bin/sh?

znmeb commented 6 years ago

@nam20485 Not really - it turns out the problem is probably a silent failure of Docker mounting the host repository into `/code/ in the container. :-(

nam20485 commented 6 years ago

Fair enough. Ignore my previous comments, I was confused with old info but I think I am up to speed now.

znmeb commented 6 years ago

A bit of an update - I spent a few hours yesterday testing on Windows 10 Pro and was unable to find a simple, repeatable way to get this task done. So I've gone nuclear ;-)

Seriously, what I did was create a new Dockerfile / compose file / script combo that doesn't mount any host files into a container. Instead it copies the inputs to the image and copies the resulting code back out to the repo.

And it's a one-step process - you edit the environment variables, copy your backup file in and run a script. When it's done you have the database image running in its container, the API image running in it's container with the scaffolding code. When you terminate it, the script copies the code to your repo.

znmeb commented 6 years ago

Fix is in pull request #49