Add Docker to macOS installation

Hi @aroswell,

Thanks for the #feature-request!

For now we don’t plan to preinstall docker on the Mac stacks, but if this request gets enough votes we’ll definitely consider it.

Why we don’t plan to preinstall it (for now): as discussed in How to use your own Docker image for your builds Docker for Mac, which is the current preferred official solution, doesn’t really work in a virtualized environment and has some other issues too.

The older Docker Toolkit does work, but it’s marked as semi-deprecated, although there are still quite a few docker tools which only work with that (e.g. docker-machine) and does not with Docker for Mac.

Other than the stability / deprecation issue resource constraints are also a factor. If an iOS build doesn’t need Docker, the resources consumed by Docker are a waste. Why does docker consume resources? Because Docker on the Mac uses a virtualized Linux to run the docker commands, as there is no native Mac support in docker. The standard Docker is built on Linux (kernel) technologies.

That said, if you need Docker on the Mac stacks, it’s definitely possible to install and use it. It takes about 30 seconds to install with brew and another ~80 seconds to boot the required host (linux virtual machine).

An example configuration using Script steps to install and start docker-toolkit:

---
format_version: 3
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
trigger_map:
- push_branch: "*"
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
workflows:
  primary:
    steps:
    - script@1.1.4:
        title: brew cask install docker-toolbox
        inputs:
        - content: |-
            #!/bin/bash
            set -ex

            brew cask install docker-toolbox
    - script@1.1.4:
        title: docker-machine create
        inputs:
        - content: |-
            #!/bin/bash
            set -ex

            docker-machine create --driver "virtualbox" default
    - script@1.1.4:
        title: use docker
        inputs:
        - content: |-
            #!/bin/bash
            set -ex

            eval $(docker-machine env default)

            docker version
            docker run hello-world

Note: you have to run the eval $(docker-machine env default) command in every Script where you want to use docker, as it only sets the environments for the script it was invoked in!

2 Likes