Use VSCode's Dev Containers plug-in with Docker containers to build a development environment

Insert image description here

Insert image description here

You need to install the plug-in https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
to install Docker

The benefits of doing this

  • Each project can run a container and be developed within the container. The related node environments are isolated, completely solving the problem of local package version dependency confusion.
  • Shared host's git configuration, if you are using alpinea version image, there is no git
  • Can be used as a linux host
  • You can use the basic image casually, and you can also build multiple images together for use.

You need to map the port when starting. For example, if your project port is 3000, add it when starting the image. -p 3000:3000

Note that it is best to use the root administrator account when starting the image.
Some images are binary files and do not have executable files. Therefore, you can specify the foreground to run when starting the image for the first time.
If it is -drunning in the background, it will run for a while and then stop immediately.

Guess you like

Origin blog.csdn.net/github_35631540/article/details/131537214