Go to the official website and choose your OS.
Docker for Mac has a problem is the disk IO performance (see docker/for-mac#77).
There is a fix (https://github.com/IFSight/d4m-nfs) which makes Docker use NFS instead of OSXFS.
NOTE: MacOS High Sierra <10.3.2 is likely to have problems with NFS (see discussion).
Follow the instructions:
-
Update docker File Sharing preferences as explained at https://github.com/IFSight/d4m-nfs (i.e. only
/tmp
directory should remain) -
Quit Docker
-
Clone repo:
git clone https://github.com/IFSight/d4m-nfs ~/d4m-nfs
- Put the following configuration in
~/d4m-nfs/etc/d4m-nfs-mounts.txt
:
/Users:/Users
/Volumes:/Volumes
/private:/private
- Run the script:
~/d4m-nfs/d4m-nfs.sh
6*) Optional Add shortcut to run d4m-nfs
:
echo "#\!/usr/bin/env bash\n/Users/`whoami`/d4m-nfs/d4m-nfs.sh" > /usr/local/bin/d4m
chmod +x /usr/local/bin/d4m
And then just run d4m
to start Docker.
NOTE: it requires root access to modify /etc/exports
, /etc/nfs.conf
, etc.
That's it.
NOTE: now you must start Docker using the same script (~/d4m-nfs/d4m-nfs.sh
or d4m
) in order it to work correctly.
D4M-NFS doesn't support FS events, but there are the workarounds for popular text editors (instructions).
Add Dockerfile
to build you application and docker-compose.yml
to configure services (see examples below).
Basic commands:
# build app container
docker-compose build app
# run setup script (bundle install, db:migrate, db:seed)
docker-compose run runner -c ./bin/setup
# setup frontend dependencies
docker-compose run webpack -c 'npm install'
# run web app
docker-compose up web
# run sidekiq
docker-compose up sidekiq
# run the whole app
docker-compose up web webpack sidekiq
# run specs
docker-compose run web rspec
# simply launch bash within app directory
docker-compose run runner
Usually, the runner
container is always running and you're working within it (install gems, run generators, tests, etc).
So, docker-compose run runner
is like vagrant ssh
.
Sometimes it's useful to have separate docker-compose
configurations (e.g. when working with microservices).
You can re-use some services (e.g. databases) by passing several configuration files:
docker-compose -f docker-compose.yml -f docker-compose-service.yml up web webpack sidekiq another_app
alias dcr='docker-compose run --rm'
alias dcu='docker-compose up'
alias dcs='docker-compose stop'
alias dstats='docker stats --format "table {{.Name}}:\t{{.MemUsage}}\t{{.CPUPerc}}"'
Webpack config:
devServer: {
contentBase: paths.dest,
clientLogLevel: 'warning',
disableHostCheck: true,
headers: { 'Access-Control-Allow-Origin': '*' },
inline: true,
overlay: true,
port: 3100,
publicPath: '/front/',
}
Rails helper:
def webpack_bundle_tag(bundle, options = {})
host = Rails.env.development? ? ENV['WEBPACK_URL'] : compute_asset_host
bundle_tag = javascript_include_tag("#{host}/front/#{Webpack.entry_path(bundle)}", options)
if bundle == 'shared' && (manifest = Webpack.manifest)
"#{javascript_tag "window.webpackManifest = #{manifest};"}\n#{bundle_tag}".html_safe
else
bundle_tag
end
end