Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker: Listen on all interfaces #83

Open
djarbz opened this issue Dec 9, 2024 · 6 comments
Open

Docker: Listen on all interfaces #83

djarbz opened this issue Dec 9, 2024 · 6 comments

Comments

@djarbz
Copy link

djarbz commented Dec 9, 2024

I run all of my containers behind a reverse proxy on the host, so there is no port mapped outside of the container network.
As such, I have a proxy network and an immich network.

This container picks the immich network to listen on port 3000 instead of all networks and, as such, my reverse proxy cannot access it.

Inside the container:

$ hostname -i
172.16.15.4 172.16.14.25
$ hostname
d91ff275f18f
docker logs -f immich_power_tools
  ▲ Next.js 14.2.5
  - Local:        http://d91ff275f18f:3000
  - Network:      http://172.16.15.4:3000

 ✓ Starting...
 ✓ Ready in 384ms
@djarbz
Copy link
Author

djarbz commented Dec 9, 2024

It is working if I modify the startServer function as such:

startServer({
  dir,
  isDev: false,
  config: nextConfig,
  hostname: '0.0.0.0',
  port: currentPort,
  allowRetry: false,
  keepAliveTimeout,
}).catch((err) => {
  console.error(err);
  process.exit(1);
});

While running in a container, we do not want the hostname set on this line and just want the ANY address. I don't know if there is a use-case if running outside of a container?

const hostname = process.env.HOSTNAME || '0.0.0.0'

@dperezq
Copy link

dperezq commented Dec 12, 2024

It's happening the same to me. I am not able to run it but no errors are shown in the logs. The browser returns me "ERR_CONNECTION_REFUSED" and no logs in the console, so I have no idea how to continue.

@djarbz
Copy link
Author

djarbz commented Dec 12, 2024

@dperezq YOU can't, unless you rewrite the server.js to listen on all interfaces and mount that in to override the one that is included.

@BoiDLi
Copy link

BoiDLi commented Dec 13, 2024

I'm encountering the same problem.
I ran the following command 'docker exec -it sh' and then edited '/app/server.js' with vi.
Then I restarted the immich-power-tools container.
I can now access immich-power-tools through the proxy but the configuration is still wrong. Still a bit of tweeking to do

@djarbz
Copy link
Author

djarbz commented Jan 3, 2025

This is a section from my Docker Compose:

  power-tools:
    container_name: immich_power_tools
    environment:
      DB_DATABASE_NAME: immich
      DB_HOST: database
      DB_PASSWORD: <REDACTED>
      DB_PORT: 5432
      DB_USERNAME: postgres
      EXTERNAL_IMMICH_URL: <REDACTED>
      GEMINI_API_KEY: <REDACTED>
      IMMICH_API_KEY: <REDACTED>
      IMMICH_URL: http://immich-server:2283
      TZ: America/Chicago
    image: ghcr.io/varun-raj/immich-power-tools:latest
    labels:
      com.centurylinklabs.watchtower.enable: 'true'
    networks:
      - ix-traefik_backend
      - stack
    ports:
      - host_ip: 100.100.1.5
        name: web-ui
        protocol: tcp
        published: 8007
        target: 3000
    restart: unless-stopped
    tmpfs:
      - /tmp
    volumes:
      - source: /mnt/apps/config/immich_power_tools_server.js
        target: /app/server.js
        type: bind

You'll see how I am mounting the modified server.js from the host FS to the container.

@nickconway
Copy link

nickconway commented Jan 6, 2025

You can listen on all interfaces by setting the HOSTNAME environment variable in the container:

environment:
      HOSTNAME: '0.0.0.0'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants