We’d have to see your Dockerfile and run command to confirm, but my suspicion is that your CMD/ENTRYPOINT is a single command that runs, and then finishes. Once it finishes, the container stops. Since you have restart: always, it starts back up, runs the command, and stops again.
Try using a docker run command without the -it You should see the same results.
You’ll likely need to change your CMD/ENTRYPOINT to something that stays up.
Dockerfile
FROM node:10
RUN mkdir rragequit
WORKDIR /rragequit
COPY . ./rragequit
RUN yarn install
# RUN yarn migrate:run
# RUN yarn seed:run
# RUN yarn start
EXPOSE 443
# CMD []
As you can see there is several problems with my dockerfile. I don’t use any CMD , also problem with RUN yarn install as it says no network connection and I need to run migrate and seed afterwards… but the problem is how can I run migrate and seed when I dont have postgres container running.
I suppose those stuff should be done in compose yml file.
But all of that should happen before I start my app. So what do you recommend for me to make this work, both dockerfile and compose.yml wise ?
When you manually use the docker run -dit command, you’ll need to document every single command you run in order to install all the necessary apps and bring them up. Put all of those commands into the Dockerfile. At this point I would recommend going through more documentation and tutorials.
I appreciate the answer, but could you be more specific about how can I run migration inside dockerfile, when I need to run postgres container first (which will happen with compose up) ?