How can you confirm everything is working properly?
schlenks opened this issue · comments
First off, this looks like an incredible project. I've been trying to improve the speed of my docker environment and figured it was due to the performance hit of virtualbox filesharing.
However, after following the setup setups, running docker-osx-dev in one terminal and then running docker-compose up in another (and letting docker-osx-dev finish syncing) I am not seeing any change in initial boot or initial load times.
Ie,
under vanilla docker setup, it takes about 1m15s to load the apps homepage. Under docker-osx-dev it takes about the same.
When I loaded up the same app in dinghy (so it uses NFS), it loads in about 39s
Given that rsync should be about 2x-3x faster than NFS, I think your project should bring the load times down to near native filesystem, which is exciting. If there's anything I'm missing or anything I can provide, more than happy to.
This is how I created the initial docker-machine:
docker-machine create --driver virtualbox --virtualbox-memory 5120 --virtualbox-disk-size 30000 --virtualbox-cpu-count 2 --virtualbox-no-share default
This is my dockerfile:
FROM ruby:2.2.3
ENV APP_HOME /app
RUN apt-get update -qq && apt-get install -y build-essential nodejs apt-utils
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install
COPY . ./
and this is my docker-compose.yml file:
web: &app_base
build: .
volumes:
- .:/app
command: bundle exec rails server -b 0.0.0.0 -p 3000
environment: &app_environment
# Run the app in the 'development' environment:
RACK_ENV: development
RAILS_ENV: development
ENABLE_DEBUG_SERVER: "true"
links:
- db
- redis
- mailcatcher
ports:
- "8989:8989"
db:
build: mysql_build
hostname: app_db
ports:
- "3306:3306" # allows connections via workbench without host interference
environment:
MYSQL_ROOT_PASSWORD: notarealpassword
# alpine based version to keep it tiny
redis:
image: tenstartups/alpine-redis
expose:
- "6379"
nginx:
build: nginx_build
ports:
- "80:80"
- "443:443"
links:
- web
mailcatcher:
image: tophfr/mailcatcher
ports:
- "1080:80"
- "1025:25"
When you run docker-osx-dev do you get any warnings like Found VirtualBox shared folders on your Boot2Docker VM. These may void any performance benefits from using docker-osx-dev
? If you had a pre-existing Boot2Docker VM, it would've already created the vboxfs shares, which are very slow. To get the speed boost from docker-osx-dev, you have to remove those shares first.
I did the first time I tried docker-osx-dev, which is why I started creating the docker-machine images with --virtualbox-no-share
the warning would disappear after that.
Here is sample output from initial creation to start of docker-osx-dev
$ docker-machine create --driver virtualbox --virtualbox-memory 5120 --virtualbox-disk-size 30000 --virtualbox-cpu-count 2 --virtualbox-no-share default
Running pre-create checks...
Creating machine...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) 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 with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect Docker to this machine, run: docker-machine env default
I ran docker-osx-dev
the first time and it did a huge sync, re-running a 2nd time so I have a more concise output for posting:
$ docker-osx-dev
2016-01-03 08:54:57 [INFO] Using sync paths from Docker Compose file at docker-compose.yml: .
2016-01-03 08:54:57 [INFO] Complete list of paths to sync: /Users/me/projects/app
2016-01-03 08:54:57 [INFO] Using excludes from ignore file .dockerignore: tmp/cache tmp/data tmp/miniprofiler tmp/pids tmp/sessions tmp/sockets log/ab_conversions.log log/access_denied.log log/bullet.log log/development.log log/newrelic_agent.log log/test.log .get /vendor/bundle .bash_history .byebug_hist .pry_history docker-compose.yml .DS_Store .quanta *.webprj *.session previous_failures.txt *.swp *.swo coverage/assets coverage/index.html nbproject/* .idea/dataSources.ids .idea/dataSources.local.xml .idea/dataSources.xml .idea/dbnavigator.xml .idea/encodings.xml .idea/misc.xml .idea/modules.xml .idea/runConfigurations .idea/app.iml .idea/vcs.xml .idea/workspace.xml .idea/workspace.xml .idea/dataSources.ids .idea/dataSources.local.xml .idea/dataSources.xml .idea/dbnavigator.xml .idea/encodings.xml .idea/misc.xml .idea/modules.xml .idea/app.iml .idea/vcs.xml .idea/workspace.xml .idea app.iml vcs.xml workspace.xml
2016-01-03 08:54:57 [INFO] Complete list of paths to exclude: tmp/cache tmp/data tmp/miniprofiler tmp/pids tmp/sessions tmp/sockets log/ab_conversions.log log/access_denied.log log/bullet.log log/development.log log/newrelic_agent.log log/test.log .get /vendor/bundle .bash_history .byebug_hist .pry_history docker-compose.yml .DS_Store .quanta *.webprj *.session previous_failures.txt *.swp *.swo coverage/assets coverage/index.html nbproject/* .idea/dataSources.ids .idea/dataSources.local.xml .idea/dataSources.xml .idea/dbnavigator.xml .idea/encodings.xml .idea/misc.xml .idea/modules.xml .idea/runConfigurations .idea/app.iml .idea/vcs.xml .idea/workspace.xml .idea/workspace.xml .idea/dataSources.ids .idea/dataSources.local.xml .idea/dataSources.xml .idea/dbnavigator.xml .idea/encodings.xml .idea/misc.xml .idea/modules.xml .idea/app.iml .idea/vcs.xml .idea/workspace.xml .idea app.iml vcs.xml workspace.xml
2016-01-03 08:54:57 [INFO] Complete list of paths to include:
2016-01-03 08:54:57 [INFO] Starting docker-osx-dev file syncing
2016-01-03 08:54:57 [INFO] Testing if docker machine is running
2016-01-03 08:54:58 [INFO] Installing rsync in the Docker Host image
2016-01-03 08:54:58 [INFO] Performing initial sync of paths: /Users/me/projects/app
2016-01-03 08:54:58 [INFO] Initial sync done
2016-01-03 08:54:58 [INFO] Watching: /Users/me/projects/app
A quick way to test if docker-osx-dev is working, or if you're still using vboxsf, is to shut down docker-osx-dev (CTRL+C
) and to create a new file under /Users/me/projects/app
(touch foo
). That file should NOT be created in your Docker image. If it is, that means you're still using the vboxsf.
Thanks, confirmed syncing is working.
with docker-osx-dev running, I ran in one terminal:
docker exec -i -t ea480910fa2a /bin/bash
and then in another terminal did a touch foo
, then checked the shell and saw it was there. rm'd the file and checked again it was gone. Quit docker-osx-dev and did a touch foo
and it did not show up.
docker-osx-dev output:
2016-01-03 14:42:46 [INFO] Syncing varsitytutors/foo: <f+++++++
2016-01-03 14:42:54 [INFO] Syncing varsitytutors/foo: *deleting
With that said, it does appear to be working, I've run the tests between docker-osx-dev & dinghy numerous times over the course of the day and it appears that after taking out the extremes (ie, first load of homepage when a new SSL cert is detected) that occasionally happen that the 2 setups have about the same speed in performance:
default setup:
cold boot (ready to take a request) 1:21
cold load home 1:01
with docker-osx-dev:
cold boot (ready to take a request) 49s
cold load home 39s
dinghy:
cold boot (ready to take a request) 49s
cold load home: 42s
While that's better than what I thought when I first started reporting this, I was really hoping to see the rsync usage pull the load times well down below the NFS speeds.
What are the numbers without using Docker?
Can you run some sort of profile to see where you're spending all your time? Perhaps you're bottlenecked by the CPU or RAM and need to give VirtualBox access to more resources.
HI @brikis98,
I've torn the system up and down a few times, and while there is a performance hit, I'm considering it as an acceptable trade-off for the portability. The main performance hit is on the initial page hit, which I believe is due to the size of our app and it's load into memory. My next tasks I'm trying to sort out is (and this is outside docker-osx-dev) why VBoxHeadless periodically spins up and uses 80-104%+ CPU when the machine is idle and having it play nicely with XCode (if it's present on the machine I see a long stream of permission denied
errors). I think I've temporarily solved the latter by uninstalling XCode and using just the Command Line Tools package which is available for download when you login to Apples Developer members area.
I'm going to mark this as closed, thank you very much for your help on this question. It prompted me to rebuild our docker imagine numerous times and better document the setup of the system as I went through it each time.
Without a doubt, your approach to speeding up docker on OS X is by far the easiest one to get working and has the least impact on the overall docker environment.