Error: connect ENOENT /var/run/docker.sock - Unable to access Docker socket for creating or managing containers in a cloud-hosted environment

I hosted my web service which uses dockerode and node-pty. When users connect using socket servers, a container is created based on a pre-defined image and alongside the node-pty is initialised using the containerId.

The problem is the container cannot be created and it gives me the docker.sock error.

Error creating container or PTY process: Error: connect ENOENT /var/run/docker.sock
    at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1610:16) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'connect',
  address: '/var/run/docker.sock'
}
PTY process not initialized. Cannot process commands.

Here’s my

  1. Source code: https://github.com/Muhammad-Owais-Warsi/Web-Terminal

  2. Docker Image:https://github.com/Muhammad-Owais-Warsi/Web-Terminal/blob/master/backend/dockerfile

So how this issue can be resolved ? How to build this image on render ?
Thanks:)

The Docker service is not available within running instances of a service. Calls to docker from within your application will fail in the manner you have described here.

Thanks for the reply. So what can be the possible solutions here?

  • Containerized Environment: Each user gets their own secure container using Dockerode.

You can’t create containers inside a service on Render, your application is already running inside a container. If you require access to Docker, Render cannot currently fulfill your needs.

1 Like

Oh, ok thank you so much.