0

I want to run a solid.js project from a Docker container but I can't connect to the web-app via local host from my browser for some reason, but I was able to successfully do this with my next.js project so I figured the setup would be similar.

Here's the steps I followed. I initialize a new solid-start project named demo via npm init solid@latest demo and make the following selections from the options provided

Which template do you want to use? --> bare
Server Side Rendering? --> yes
Use TypeScript? --> no

Then I navigate into the demo folder and hit npm install and start up the project with npm run dev, when I open http://localhost:3000/ on my web browser the demo counter web-app runs fine.

Now the issue comes up when I want to introduce Docker into the mix. I create a Dockerfile inside my root directory with the following configuration

FROM node:20-alpine

WORKDIR /app

COPY package.json .

RUN npm install

COPY . .

EXPOSE 3000

CMD ["npm", "run", "dev"]

and also include the following .dockerignore file in the same folder

/node_modules
Dockerfile
.gitignore
.dockerignore
.solid

I then open docker desktop and execute the following command in my project folder docker build -t demo-image:v0 . to create a docker image of my project, which correctly shows up under my Images in docker desktop.

Then to create and run the corresponding docker container I execute the following command docker run --name demo-container --rm -p 3000:3000 demo-image:v0 which again, correctly shows up under my Containers in docker desktop as a running instance.

Now when I go to http://localhost:3000/ in my web browser, I get

This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE

strangely this time.

I've also tried older versions of alpine for the base image and various other parent images, but I get the same issue. The weird thing is that I follow a similar procedure when working with next.js projects and even tried manually doing each instruction inside the Dockerfile to validate my settings and it seems to work just fine. I'm not sure if I'm missing something or if solid.js is not compatible with Docker just yet somehow, but any guidance would be greatly appreciated, thank you.

Salim
  • 1
  • 1
  • Often dev servers bind to the localhost address 127.0.0.1, but in Docker this is a container-private localhost and the server isn't reachable from outside its own container. [running a vite dev server inside a docker container](https://stackoverflow.com/questions/70012970/running-a-vite-dev-server-inside-a-docker-container) is a different framework but a similar issue, for example. Is there a config setting you need to change to make the dev server listen on 0.0.0.0 ("all interfaces")? – David Maze Aug 26 '23 at 10:02

0 Answers0