Skip to content

Commit b48f0b2

Browse files
committed
New post about Dockero in the local devenv
1 parent 5ba3b61 commit b48f0b2

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

content/blog/dockero-host.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
+++
2+
date = '2026-02-03'
3+
title = 'Dockero in the Local Development Environment'
4+
summary = 'How to configure Dockero to work with alternative Docker runtimes in development'
5+
+++
6+
7+
I've been using the excellent [Dockero](https://github.com/the-abra/dockero) library for running some Docker containers in my web applications. In production environments the applications are running on the actual Docker runtime, but in my development environment I like to use alternatives.
8+
9+
Specifically, when I started using macOS again recently, I first opted for [Colima](https://github.com/abiosoft/colima) for its simplicity. However, anything involving Docker in my local development environment broke, and it took me a while to figure out what was wrong.
10+
11+
It took a while to figure out that the Dockero expects the Docker Unix socket to be at `/var/run/docker.sock`, but Colima has it at `~/.colima/default/docker.sock`.
12+
13+
To make Dockero work, you have to set the `DOCKER_HOST` environment variable. For my [Express](https://expressjs.com/)-based application this meant adding to `.env` (no `$HOME` variable substitution here unfortunately):
14+
15+
```properties
16+
DOCKER_HOST=unix:///Users/lptr/.colima/default/docker.sock
17+
```
18+
19+
I also had some tests using [Jest](https://jestjs.io/) that involved executing Docker containers. Fixing those was a bit more complicated.
20+
21+
I first installed [`dotenv`](https://github.com/motdotla/dotenv):
22+
23+
```shell
24+
npm install dotenv --save-dev
25+
```
26+
27+
Then in `jest.config.ts` I added:
28+
29+
```ts
30+
import type { Config } from 'jest';
31+
32+
export default {
33+
// ...
34+
setupFiles: ['./jest.setup.ts'],
35+
} as Config;
36+
```
37+
38+
And in `jest.setup.js`:
39+
40+
```ts
41+
import { config } from 'dotenv';
42+
43+
config({
44+
path: '.env.test',
45+
quiet: true,
46+
});
47+
```
48+
49+
This loads a `.env.test` file before tests executed by Jest, so I can also put the `DOCKER_HOST` in there.
50+
51+
I then later switched from Colima to [Rancher Desktop](https://rancherdesktop.io/). To make things work once again I had to change both `.env` files:
52+
53+
```properties
54+
DOCKER_HOST=unix:///Users/lptr/.rd/docker.sock
55+
```

0 commit comments

Comments
 (0)