K6 browser docker fail to start chromium with system_bus_socket error

Hi,

When run the following k6 with browser test,

docker run --platform linux/amd64 --rm -i -v $(pwd):/home/k6/screenshots -e K6_BROWSER_HEADLESS=false grafana/k6:latest-with-browser run - <script.js

which script.js same as sample in Running browser tests (k6.io)

I got the following error:

      /\      |‾‾| /‾‾/   /‾‾/   
 /\  /  \     |  |/  /   /  /    
/  \/    \    |     (   /   ‾‾\  

/ \ | |\ \ | (‾) |
/ __________ \ |__| _\ ____/ .io

 execution: local
    script: -
    output: -

 scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
          * ui: 1 iterations shared among 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

time=“2024-04-20T00:08:38Z” level=error msg=“process with PID 21 unexpectedly ended: exit status 1” category=browser elapsed=“0 ms” source=browser

 data_received........: 0 B 0 B/s
 data_sent............: 0 B 0 B/s
 iteration_duration...: avg=751.08µs min=751.08µs med=751.08µs max=751.08µs p(90)=751.08µs p(95)=751.08µs
 iterations...........: 1   2.886941/s

running (00m00.3s), 0/1 VUs, 0 complete and 1 interrupted iterations
ui ✗ [ 100% ] 1 VUs 00m00.3s/10m0s 1/1 shared iters
time=“2024-04-20T00:08:39Z” level=error msg=“error building browser on IterStart: launching browser: Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory at file:///-:16:15(0)”

Environment is MacBook M3 OS 14.4.1.

Without using docker the browser has no issue to pop up. But when using docker it just doesn’t work. Because it is a company laptop, we will not have permission to access system_bus_socket. Even we do, I don’t think it is a good idea to expose system socket.

So the solution seems need to rebuild docker to deal with this issue? Any tips?

Hi @syow , welcome to the community forum!

I think, this happens because you don’t have graphical system inside the docker container. I assume You can just run the script fine with: -e K6_BROWSER_HEADLESS=true

1 Like