mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-18 09:55:19 +00:00
Merge pull request #4171 from rpoetrap/fix/docker-host
fix: invalid docker host while using docker desktop
This commit is contained in:
@@ -11,10 +11,24 @@ export const isWSL = async () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Returns if running in Docker Desktop. */
|
||||||
|
export const isDockerDesktop = async () => {
|
||||||
|
try {
|
||||||
|
const { stdout } = await execAsync("getent hosts host.docker.internal");
|
||||||
|
return !!stdout.trim();
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Returns the Docker host IP address. */
|
/** Returns the Docker host IP address. */
|
||||||
export const getDockerHost = async (): Promise<string> => {
|
export const getDockerHost = async (): Promise<string> => {
|
||||||
if (process.env.NODE_ENV === "production") {
|
if (process.env.NODE_ENV === "production") {
|
||||||
if (process.platform === "linux" && !(await isWSL())) {
|
const isLinux = process.platform === "linux"
|
||||||
|
? (await Promise.all([isWSL(), isDockerDesktop()])).every((v) => !v)
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (isLinux) {
|
||||||
try {
|
try {
|
||||||
// Try to get the Docker bridge IP first
|
// Try to get the Docker bridge IP first
|
||||||
const { stdout } = await execAsync(
|
const { stdout } = await execAsync(
|
||||||
|
|||||||
Reference in New Issue
Block a user