-
Download Docker for OSX from https://docs.docker.com/engine/installation/mac/
-
Install an alias for your host machine's local loopback network interface. This allows the docker containers to communicate with the host machine on the specified ip address.
Create the following file at
/usr/local/bin/login-script
:#!/bin/sh # add a local loopback alias for docker ifconfig lo0 alias 10.0.2.2
Then run the following commands:
sudo chmod +x /usr/local/bin/login-script sudo defaults write com.apple.loginwindow LoginHook /usr/local/bin/login-script
-
Modify the RabbitMQ/Mongo configuration files to allow connections from any host (i.e. docker containers)
# in /usr/local/etc/rabbitmq/rabbitmq-env.conf find and modify the following line
NODE_IP_ADDRESS=0.0.0.0
And also allow non-localhost connections for the guest user
sudo sh -c 'echo "[{rabbit, [{loopback_users, []}]}]." > /usr/local/etc/rabbitmq/rabbitmq.config'
sed -i .bak "s/bindIp: .*/bindIp: 0.0.0.0/" /usr/local/etc/mongod.conf
sed -i .bak "s/^bind 127.0.0.1$/bind 127.0.0.1 10.0.2.2/" /usr/local/etc/redis.conf
grep -q 10.0.2.2 /usr/local/var/postgres/pg_hba.conf || echo 'host all all 10.0.2.2/32 trust' >> /usr/local/var/postgres/pg_hba.conf
sed -E -i .bak "s/^#?listen_addresses = 'localhost'/listen_addresses = 'localhost,10.0.2.2'/" /usr/local/var/postgres/postgresql.conf
Also modify your memcached plist at /usr/local/opt/memcached/homebrew.mxcl.memcached.plist
to change localhost
to localhost,10.0.2.2
-
Restart your computer
-
You're done! consider installing the docker-compose aliases to make your life much easier when working with docker.
Your docker containers will be available through
localhost
Insert the following into your ~/.bash_aliases
file feel free to add your own
and consider contributing it.
alias dc='docker-compose '
alias dc-run='dc run --rm '
alias web-run='dc-run web '
alias web-bundle='web-run bundle '
alias web-rails='web-bundle exec rails '
alias web-rake='web-bundle exec rake '
alias web-rspec='web-bundle exec rspec '
Depending on the image you're updating, you may have 1 or 2 steps to go through. If you're modifying a base
image, that is, an image that other images use, you'll need to re-publish the base image AND images that use that base image. If you're just modifying an end-user image, you can just update and publish that one.
- Commit and PR your changes
- in the base image directory (eg
/ruby
) rundocker build -t influitive/ruby .
- Push that base image using
docker push influitive/ruby
.
This will push up influitive/ruby:latest
.
Note that other images that have already been built with the previous influitive/ruby
image as their FROM
will now need to be updated also (if they want those changes). To do this,
- go into the appropriate folder of the image you want to modify (eg,
onbuild
ordev
) - rebuild the tagged image using the new base image
docker build -t influitive/ruby:onbuild .
- re-tag any other matching tags (such as the ruby version tag)
docker build -t influitive/ruby:onbuild-2.3
- push any tagged images up using
docker push influitive/ruby:onbuild-2.3
for each tagged image