You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The actual docker commands do not launch the container, it stops immediatly after running.
the command docker container run --name micro-api -p 3000:3000 -dt micro-api yarn has the following output:
The issue come from the 'yarn' keyword at the end of the command line. By doing docker container run --name micro-api -p 3000:3000 -dt micro-api without any change on the dockerfile file, the container run and we have the following output:
2024-12-17 15:04:08 Welcome to Node.js v22.12.0.
2024-12-17 15:04:08 Type ".help" for more information.
It looks like the image actually don't lauch the server
So to make it works as intended, we have to build the image with this dockerfile:
FROM node:lts-alpine
ADD . /app/
WORKDIR /app
RUN yarn
CMD [ "node", "app/index.js" ]
EXPOSE 3000
and then docker container run --name micro-api -p 3000:3000 -dt micro-api,
Now the output is "2024-12-17 15:05:38 Magic happens on port 3000" as intended
I verified it with postman, and I can now retrieve the data from the API
The text was updated successfully, but these errors were encountered:
The actual docker commands do not launch the container, it stops immediatly after running.
the command
docker container run --name micro-api -p 3000:3000 -dt micro-api yarn
has the following output:yarn install v1.22.22
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.22s.
The issue come from the 'yarn' keyword at the end of the command line. By doing
docker container run --name micro-api -p 3000:3000 -dt micro-api
without any change on the dockerfile file, the container run and we have the following output:2024-12-17 15:04:08 Welcome to Node.js v22.12.0.
2024-12-17 15:04:08 Type ".help" for more information.
It looks like the image actually don't lauch the server
So to make it works as intended, we have to build the image with this dockerfile:
and then
docker container run --name micro-api -p 3000:3000 -dt micro-api
,Now the output is "2024-12-17 15:05:38 Magic happens on port 3000" as intended
I verified it with postman, and I can now retrieve the data from the API
The text was updated successfully, but these errors were encountered: