首页 > 解决方案 > Change default run command of VSC Docker extension

问题描述

When right-clicking on an image in Microsoft's Docker plugin and selecting run it executes the following command:

docker run --rm -d -p 3000:3000/tcp falaen:latest

I would like it to run the following command instead:

docker run --restart=always -v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock -p 3000:3000 -d falaen

I have tried to modify the run command in the Dockerfile but without success. Of course, I can run the command manually in the terminal each time but it would be nicer to simply right click on the image and then run it.

标签: node.jsdockervisual-studio-code

解决方案


您可以尝试将此行添加到您的 VSCode 中settings.json,以覆盖命令的默认配置。

"docker.commands.run": "docker run --restart=always -v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock -p 3000:3000 -d ${tag}"

这将使用您选择的任何图像运行命令。


推荐阅读