Dockerized Create React App 无法打开新标签页



在使用Docker运行应用程序时,我注意到一个奇怪的行为——它没有打开新的选项卡。如果我用npm/yarn启动手动运行我的应用程序,选项卡会很好地打开。

没有有"BROWSER=none";in.env

这是因为create-react-app启动脚本试图打开本地浏览器。以下是启动脚本的相关部分之一:

/**
* Attempts to open the browser with a given URL.
*
* On Mac OS X, attempts to reuse an existing Chrome tab via AppleScript.
*
* Otherwise, falls back to [open](https://github.com/sindresorhus/open) behavior.
*/
declare function openBrowser(url: string): boolean;
export = openBrowser;

但是,如果您的应用程序在docker容器中运行,则它就像在单独的机器(VM(上运行一样。它没有安装浏览器。

Docker容器的工作方式是,它们不能只调用主机的程序(没有相当复杂的解决方法(。

最新更新