# Curl --unix-socket in node-red?

**URL:** https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488
**Category:** General
**Created:** [11 May 2022 05:38 UTC](https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488 "2022-05-11T05:38:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [11 May 2022 05:38 UTC](https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488/1 "2022-05-11T05:38:16Z")

</div>

I am trying to reinvent the "portainer" wheel by creating my own docker container manager in node-red.  
Docker engine has an API that can be called by using something like:

```auto
curl --unix-socket /var/run/docker.sock http://localhost/v1.41/containers/json

```

to list all containers.

This will work with an exec node (after fighting permissions), but I find this too simple, is there a "node-red" way of doing it ? It is not a "normal" http-request, the `--unix-socket` part would be a tcp connection I believe, but I am not sure how this works.

---

<div class="post-metadata">

### Author: ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)
#### Post date: [11 May 2022 06:56 UTC](https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488/2 "2022-05-11T06:56:34Z")

</div>

Use the dockerode node [node-red-contrib-dockerode (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-dockerode)

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [11 May 2022 16:00 UTC](https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488/3 "2022-05-11T16:00:56Z")

</div>

Hmm interesting, i cannot get it to work on a remote node, but this looks promising thanks!

---

<div class="post-metadata">

### Author: ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)
#### Post date: [11 May 2022 16:08 UTC](https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488/4 "2022-05-11T16:08:29Z")

</div>

For remote you'll need to enable true tcp/http on the docker engine to allow remote connections.

But also the http-request node uses got so you might be able to use a url like this:

`http://unix:/var/run/docker.sock:/containers/json`

> <https://github.com/sindresorhus/got/blob/main/documentation/tips.md#unix>

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [11 May 2022 16:15 UTC](https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488/5 "2022-05-11T16:15:16Z")

</div>

> For remote you'll need to enable true tcp/http on the docker engine to allow remote connections.

Yes I have "managed" to configure that part, but I think there is also some firewall/iptables stuff blocking the road somewhere.

I am not sure what you mean with the http-request node, unless you mean to use that for localhost only ?

---

<div class="post-metadata">

### Author: ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)
#### Post date: [11 May 2022 16:17 UTC](https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488/6 "2022-05-11T16:17:35Z")

</div>

It was about the original unix domain socket question, I just meant it should be possible to access a domain socket with the http-request node (but only on the local machine)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [25 May 2022 16:18 UTC](https://discourse.nodered.org/t/curl-unix-socket-in-node-red/62488/7 "2022-05-25T16:18:02Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
