brikis98 / docker-osx-dev

A productive development environment with Docker on OS X
http://www.ybrikman.com/writing/2015/05/19/docker-osx-dev/
MIT License
1.43k stars 106 forks source link

(Installing and)Synching gets to "Testing if docker machine is running" and stops #148

Closed richardtape closed 8 years ago

richardtape commented 8 years ago

First, thanks so much for putting this together. It is precisely what I've been struggling with over the weekend.

Following the steps in the readme, I created a machine using docker-machine thus

docker-machine create --driver virtualbox spaces

Running pre-create checks...
Creating machine...
(spaces) OUT | Creating VirtualBox VM...
(spaces) OUT | Creating SSH key...
(spaces) OUT | Starting VirtualBox VM...
(spaces) OUT | Starting VM...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Detecting the provisioner...
Provisioning created instance...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
To see how to connect Docker to this machine, run: docker-machine env spaces

eval "$(docker-machine env spaces)"

docker-osx-dev install

2015-11-30 10:55:27 [INFO] Starting install of docker-osx-dev
2015-11-30 10:55:27 [INFO] Updating HomeBrew
Already up-to-date.
2015-11-30 10:55:34 [WARN] Cask is already installed by HomeBrew, skipping
2015-11-30 10:55:34 [WARN] Found command boot2docker, assuming Boot2Docker is already installed and skipping
2015-11-30 10:55:34 [WARN] Found command docker-compose, assuming Docker Compose is already installed and skipping
2015-11-30 10:55:34 [WARN] Found command docker-machine, assuming Docker Machine is already installed and skipping
2015-11-30 10:55:34 [WARN] Found command fswatch, assuming fswatch is already installed and skipping
2015-11-30 10:55:34 [WARN] Found command greadlink, assuming GNU core utilities is already installed and skipping
2015-11-30 10:55:34 [INFO] Testing if docker machine is running

docker-osx-dev

2015-11-30 10:55:48 [INFO] Using default sync paths: .
2015-11-30 10:55:48 [INFO] Complete list of paths to sync: /Users/<snip>/sites/ctlt/docker-test/data
2015-11-30 10:55:48 [INFO] Using default exclude paths: .git
2015-11-30 10:55:48 [INFO] Complete list of paths to exclude: .git
2015-11-30 10:55:48 [INFO] Complete list of paths to include: 
2015-11-30 10:55:48 [INFO] Starting docker-osx-dev file syncing
2015-11-30 10:55:48 [INFO] Testing if docker machine is running

Manually ran docker-machine status spaces and got Running

Then, in another tab

docker run -d -p 80:80 -v /Users/<snip>/sites/ctlt/docker-test/data:/var/www richardtape/spacesnginx:latest nginx

Unable to find image 'richardtape/spacesnginx:latest' locally
latest: Pulling from richardtape/spacesnginx
fa5be2806d4c: Pull complete 
0cd86ce0a197: Pull complete 
e9407f1d4b65: Pull complete 
c9853740aa05: Pull complete 
e9fa5d3a0d0e: Pull complete 
de3bdb6852ec: Pull complete 
73329e4a2aa1: Pull complete 
Digest: sha256:ed6b9cdd1c62ac4d2f9f24d8cb10eaa7b499d42609a19078147b1c2507bbe9fc
Status: Downloaded newer image for richardtape/spacesnginx:latest
e2c1eaa5f86af37497ad1996da526528b158e5a09d5efc1d91334b9ea55cd941

docker ps -a

CONTAINER ID        IMAGE                            COMMAND             CREATED             STATUS              PORTS                NAMES
e2c1eaa5f86a        richardtape/spacesnginx:latest   "nginx"             6 seconds ago       Up 6 seconds        0.0.0.0:80->80/tcp   reverent_goldberg

docker-machine ip spaces 192.168.99.101

Visit 192.168.99.101 in a browser and I see the index.html file in my shared data directory. However, if I update that file on the host (i.e. using Atom on my host mac to update /Users/<snip>/sites/ctlt/docker-test/data/index.html) the changes aren't reflected when I refresh the browser.

OSX: 10.10.5 Virtualbox: 5.0.10 Docker version 1.9.1, build a34a1d5 fswatch 1.7.0 readlink (GNU coreutils) 8.24

I'm probably doing something stupid...

richardtape commented 8 years ago

As an addition, if I docker exec -i -t e2c1eaa5f86a /bin/bash into the container and then

cat /var/www/index.html

I can see that the file has been updated with the change I made on the host. But they are not reflected in the browser. Maybe I'm being very, very stupid, but I thought this was exactly what docker-osx-dev was designed to do?

Could it be that by default the /Users/directory is a shared folder? And that because I'm sharing something else already in that directory, that docker-osx-dev isn't syncing?

Simperfit commented 8 years ago

Hello Richard

What url are you using to access the file ?

For exemple :

192.168.99.101/index.html will be the same as /var/www/index.html (if the nginx vhost has been configure to use that path)

As I can see there is no docker-compose.yml and no -s flag.

So he is not watching anything.

Try again with the -s file or use a docker-compose.yml file in order to sync the volumes.

Simp'

richardtape commented 8 years ago

Hi, thanks so much for getting back to me. Yes I'm using 192.168.99.101/index.html to view the file. And yes, it's the same as /var/www/index.html (the nginx config has been set to show that).

Sorry, I'm being silly, but if I'm already in the shared directory, I don't need the -s flag do I?

On my Mac, the files are in /Users/<snip>/sites/ctlt/docker-test/data/

So if I cd /Users/<snip>/sites/ctlt/docker-test/data/ and then docker-osx-devthat's the same as running docker-osx-dev -s /Users/<snip>/sites/ctlt/docker-test/data/no?

richardtape commented 8 years ago

If I manually run docker-osx-dev -s /Users/<snip>/sites/ctlt/docker-test/data it does the same thing, i.e.

2015-11-30 12:30:30 [INFO] Using sync paths from command line args: /Users/<snip>/sites/ctlt/docker-test/data
2015-11-30 12:30:30 [INFO] Complete list of paths to sync: /Users/<snip>/sites/ctlt/docker-test/data
2015-11-30 12:30:30 [INFO] Using default exclude paths: .git
2015-11-30 12:30:30 [INFO] Complete list of paths to exclude: .git
2015-11-30 12:30:30 [INFO] Complete list of paths to include: 
2015-11-30 12:30:30 [INFO] Starting docker-osx-dev file syncing
2015-11-30 12:30:30 [INFO] Testing if docker machine is running

If I then edit /Users//sites/ctlt/docker-test/data/index.html on my host, the change is not reflected when I visit http://192.168.99.101/index.html in a browser.

brikis98 commented 8 years ago

The part that says "Testing if docker machine is running" is executing the following command:

docker-machine status $DOCKER_MACHINE_NAME

What happens if you run that separately in a terminal?

richardtape commented 8 years ago

From my initial comment:

Manually ran docker-machine status spaces and got Running

(spaces is the name of $DOCKER_MACHINE_NAME and, to confirm, docker-machine status $DOCKER_MACHINE_NAME also returns Running and echo $DOCKER_MACHINE_NAME returns spaces)

brikis98 commented 8 years ago

I see. If it's not the docker-machine status call, then it must be hanging on something else. You could try running docker-osx-dev with the debug logging flag (-l DEBUG) to see if you get more output. If that doesn't do it, the next best option is to manually add log statements to the script itself to see where it's hanging.

richardtape commented 8 years ago

docker-osx-dev -l DEBUG

2015-11-30 12:51:15 [INFO] Using default sync paths: .
2015-11-30 12:51:15 [INFO] Complete list of paths to sync: /Users/<snip>/sites/ctlt/docker-test/data
2015-11-30 12:51:15 [INFO] Using default exclude paths: .git
2015-11-30 12:51:15 [INFO] Complete list of paths to exclude: .git
2015-11-30 12:51:15 [INFO] Complete list of paths to include: 
2015-11-30 12:51:15 [INFO] Starting docker-osx-dev file syncing
2015-11-30 12:51:15 [INFO] Testing if docker machine is running

I'll throw some logs into the file and see what happens

richardtape commented 8 years ago

OK, got it.

It was hanging on

DOCKER_HOST_USER=$(inspect_docker_machine "{{.Driver.SSHUser}}")
DOCKER_HOST_IP=$(inspect_docker_machine "{{.Driver.IPAddress}}")

in configure_docker_machine()

I ran an inspect and it shows me that the correct location should be

DOCKER_HOST_USER=$(inspect_docker_machine "{{.Driver.Driver.SSHUser}}")
DOCKER_HOST_IP=$(inspect_docker_machine "{{.Driver.Driver.IPAddress}}")

(Driver.Driver. not Driver.)

I changed that, then ran docker-osx-dev and it gave me a LOT more output, including noticing that there were already shared folders (as expected) and then, ultimately,

2015-11-30 13:24:58 [INFO] Syncing data/: cd+++++++
2015-11-30 13:24:58 [INFO] Syncing data/index.html: <f+++++++
2015-11-30 13:24:58 [INFO] Initial sync done
2015-11-30 13:24:58 [INFO] Watching: /Users/<snip>/sites/ctlt/docker-test/data
2015-11-30 13:24:58 [DEBUG] fswatch -0 /Users/<snip>/sites/ctlt/docker-test/data

Perhaps the location of the SSHUser and IPAddress changed recently in the output from a docker-machine inspect?

brikis98 commented 8 years ago

@richardtape: Thanks for digging in!

@lukaso: Any thoughts?

richardtape commented 8 years ago

I can make a PR here if you're interested?

Probably do something like you did with DOCKER_MACHINE_STORE_PATH by doing an || check?

brikis98 commented 8 years ago

Sure, that would be great! Perhaps the Docker folks are changing these config paths and we just need to keep up from time to time.@lukaso, feel free to pipe in if you have any thoughts.

lukaso commented 8 years ago

@brikis98 I think the docker people are simply moving things around under the hood in this API without documentation. I wonder if we should open an issue asking them to at least document when they make the changes. Or we should build slightly more abstraction into here though it's not looking too bad yet.