I use Docker to contain my Adonis app. The build was success but when I access the app, I got ERR_SOCKET_NOT_CONNECTED
or ERR_CONNECTION_RESET
.
My docker compose contains adonis and database. Previously, I use the setup similar with this for my expressjs app, and it has no problem.
The adonis .env is remain standard, modification.
This is my setup:
JavaScript
x
30
30
1
# docker-compose.yml
2
3
version: '3'
4
services:
5
adonis:
6
build: ./adonis
7
volumes:
8
- ./adonis/app:/usr/src/app
9
networks:
10
- backend
11
links:
12
- database
13
ports:
14
- "3333:3333"
15
16
database:
17
image: mysql:5.7
18
ports:
19
- 33060:3306
20
networks:
21
- backend
22
environment:
23
MYSQL_USER: "user"
24
MYSQL_PASSWORD: "root"
25
MYSQL_ROOT_PASSWORD: "root"
26
27
networks:
28
backend:
29
driver: bridge
30
JavaScript
1
19
19
1
# adonis/Dockerfile
2
3
FROM node:12-alpine
4
5
RUN npm i -g @adonisjs/cli
6
7
RUN mkdir -p /usr/src/app
8
9
WORKDIR /usr/src/app
10
11
COPY ./app/. .
12
13
RUN npm install
14
15
EXPOSE 3333
16
17
CMD ["adonis", "serve", "--dev"]
18
19
I couldn’t spot anything wrong with my setup.
Advertisement
Answer
The serve command starts the HTTP server on the port defined inside the .env
file in the project root.
You should have something like this(note that HOST
has to be set to 0.0.0.0
instead of localhost
to accept connections from the outside):
JavaScript
1
4
1
HOST=0.0.0.0
2
PORT=3333
3
APP_URL=http://${HOST}:${PORT}
4