简体   繁体   中英

Dockerized Create React App doesn't open a new tab

I noticed a strange behavior when running my app with Docker - it doesn't open a new tab. If I run my app manually with npm/yarn start, tab opens fine.

I don't have "BROWSER=none" in .env

It's because the create-react-app start script tries to open the local browser. Here's one of the relevant parts of the start script:

/**
 * 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;

However, if your application is running in a docker container, it's like it is running on a separate machine, or VM. Which doesn't have a browser installed.

And the way Docker containers work, they can't just invoke programs of the host machine (without rather complex workarounds).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM