How to debug linux on a mac

February 2021

I recently encountered a bug that only appeared in our ubuntu CI server but not in my local dev environment, which is a mac. After unsuccessfully trying out 2, 3 things (pushing, waiting for the pipelines) I thought “there must be a better way, a way to test this locally”. Of course, docker comes to mind.

It’s actually really easy to set up linux on your mac without bending over backwards! You’ll simply need a command like this:

docker run -it --volume /path/to/repo:/repo ubuntu bash

or if you have a specific image on your CI like in my case

docker run -it --volume /path/to/repo:/repo runnerimage bash

What’s happening here:

If you lose the connection to the container you can reattach to it with

docker exec -it container_name_or_id bash
Become a better web developer by staying up to date