• 10-15 containers (Some Rails apps, Postgres, Elasticsearch, Redis, RabbitMQ, Nginx etc.) • CI: 1-3 containers per build, in parallel • “Production” (getting jobs into our platform) • Main staging & production is not on Docker
complex abstractions? • Isn’t a VM (Vagrant) all you need? • Isn’t Docker just for production / CI? • Docker is fiddly to get right for development, but I think it is possible!
run —net dev —detach —name postgres postgres:9.6 • docker run —net dev —interactive — tty —env DATABASE_HOST=postgres.dev —volume $PWD:/todo —name todo ruby: 2.4 rails c
which are shared between projects (e.g. message bus, database, search) • Configuration directory for services (bind-mounted) • bin directory can contain wrapper scripts, e.g. todo: #!/bin/bash crane run todo sh -c “$*" • Put bin in $PATH: todo rails c • Config update, new service, Ruby version change, etc.: git pull
user with UID 1000 for file sharing • Bind-mount another directory to place local gems: volume: […, ”local-gems:/local-gems”] In the Gemfile: gem "foo", path: "/local-gems/foo" • Bind-mount the SSH agent socket: volume: […, ”$SSH_AUTH_SOCK:/ssh-agent”] env: ["SSH_AUTH_SOCK=/ssh-agent"] • Use local history file to preserve Pry history across container runs: .pryrc Pry.config.history.file = “./pry_history”
data, e.g. a database snapshot? • Bake into image • Super-easy to distribute and reset • Docker images are not made for this • Distribute separately and store in volume • Gzipped tarballs • Import script to re-create volumes and extract data into it
easy now, but slow • However, when we started with Docker in 2015, there was no “native” solution for Mac, so … • The first setup was a Vagrant-managed VM • Docker server runs in VM, client runs on host • Problem: The server doesn’t know the paths the client specifies docker run -v /host/path:/container/path
other way around ➡ Vagrant doesn’t support this, but if the NFS server is in the VM and the client is on the Mac host, the performance in the VM is much better • However, some operations on the host are very slow now (git status) …
year, then came “native” Docker for Mac • Yes! Finally we can drop the VM, the complicated Unsion setup, and all the weird workarounds • Sure it’s fast, right?
to be cumbersome to use ✓ Our setup time went from 1-2 days (for one project only) to about 30 minutes (for all projects) ✓ Shipping service and config updates is super-easy ✓ Once setup, profit again and again from it (e.g. parallelise tests in CI, experiment with cluster setups locally, preview environments, etc.) ✓ Unified dev environment across operating systems and teams