Listen to changes and reload container on code change - docker-compose

后端 未结 2 1528
终归单人心
终归单人心 2021-02-19 07:42

I am using docker-compose in visual studio 2019 with docker for windows running linux containers. I want to enable hot reload for the angular client app.

I modified the

相关标签:
2条回答
  • 2021-02-19 08:33

    Use nodemon to automatically restart the node server when code is changed . Before that install nodemon in your docker image and make sure it is present.

    Refer this URL to install nodemon :https://www.npmjs.com/package/nodemon

    then change your CMD in Dockerfile

    CMD ["nodemon", "--exec", "npm", "run", "docker-start"]
    

    This is reload your nodejs application whenever codes are changed

    0 讨论(0)
  • 2021-02-19 08:34

    You might be facing several issues here, since Docker and Windows don't get along all to well unfortunately.

    The cannot GET\ error is defenitely weird and should not occur. First you might want to verify that your volume was mounted correctly and all data are there after running the container.

    If the working directory inside your container is empty (which might be the case) you could try to check your docker settings, whether the required drives are shared correctly.

    If they are and you still cannot see any data you might want to reset your credentials. This requires you to provide your windows password to docker.

    The bad News

    The bad news is, that apparently the inotify event (which is used to detect changes on mounted volumes) does not work with Docker on Windows yet, according to the Docker Docs. You might want to follow their recommendations on how to get around that issue.

    The good News

    Luckily, there are many projects which attempt to solve your problem, such as Go-Touch. I haven't verified that myself, but I hope you will benefit from them.

    0 讨论(0)
提交回复
热议问题