dockerode
dockerode copied to clipboard
Specifying socketPath but Dockerode is using HTTP. (bun.js)
Hi, I'm initializing dockerode like this:
const docker = new Docker({socketPath: '/var/run/docker.sock'});
but when I use it, it gives the following error:
Could not get container information. ConnectionRefused: Unable to connect. Is the computer able to access the url?
path: "http://localhost/containers/b81d1747b4d9/json"
I am using Bun.
An into the same problem ... not sure how that would happen. Maybe a permission thing?
Maybe it matters: my Docker daemon version is 1.24, this is my test code:
import Docker from 'dockerode';
const docker = new Docker({ socketPath: '/var/run/docker.sock' });
The error:
/tmp/dockerode · sudo bun run index.ts
Error: ConnectionRefused: Unable to connect. Is the computer able to access the url?
path: "http://localhost/containers/json?all=true"
Debug info:
/tmp/dockerode · ls -la /var/run/docker.sock
srw-rw---- 1 root docker 0 Oct 18 16:16 /var/run/docker.sock
/tmp/dockerode · docker info
Client:
Version: 24.0.6
Context: default
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 2
Server Version: 24.0.6
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: true
Native Overlay Diff: false
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc sysbox-runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8c087663b0233f6e6e2f4515cee61d49f14746a8.m
runc version:
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.5.7-zen2-1-zen
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 23.26GiB
Name: nine
ID: 29c770ff-e2ff-4c97-84e9-1e3da89486ae
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Investigating
I can't reproduce that :( Tried exactly the same scenario bun and nodejs.
running into same problem. using bun v1.0.7 on mac
This seems to be a problem with bun. See https://github.com/oven-sh/bun/issues/6055
Now I can reproduce it using bun (forgot mocha was evoking node) :) Indeed is seems something related with bun, not much we can do right now.
Temporary solution I'm using:
Run this command:
socat TCP-LISTEN:3000,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock
Use it like this:
new Dockerode({protocol: 'http', host: 'localhost', port: 3000})
Hello, is there any fix for this issue to get linux socket to work?
There is a pull request, but no response yet.
@recanman it looks like they merged another pull request that should fix it https://github.com/oven-sh/bun/pull/9284
Should be safe to close this issue
Great, thank you! Mentioning author: @Fumaz
I am using [email protected]
via deno, and I am still getting this issue.