Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project launched with docker not working as intended #24

Open
Theldwuyn opened this issue Dec 17, 2024 · 0 comments
Open

Project launched with docker not working as intended #24

Theldwuyn opened this issue Dec 17, 2024 · 0 comments

Comments

@Theldwuyn
Copy link

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:

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
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant