maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.24k stars 639 forks source link

Error: listen EACCES: permission denied 0.0.0.0:80 #503

Open aconital opened 3 years ago

aconital commented 3 years ago

I have a simple ubuntu server and when I run the following command: docker run --rm -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl I get this error:

    at Server.setupListenHandle [as _listen2] (net.js:1263:19)
    at listenInCluster (net.js:1328:12)
    at Server.listen (net.js:1415:7)
    at Function.listen (/app/node_modules/express/lib/application.js:618:24)
    at start (/app/src/server.js:450:22)
    at module.exports.opts (/app/src/server.js:469:19)
    at startServer (/app/src/main.js:80:29)
    at fs.stat (/app/src/main.js:211:12)
    at FSReqWrap.oncomplete (fs.js:154:5)
Emitted 'error' event at:
    at emitErrorNT (net.js:1307:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)

I tried running it with sudo as well but same thing. I had no issue running the same command on the same server last week.

eitProp commented 3 years ago

I got this error as well while trying to run v3.1.1. I also tried running the same command with v3.1.0, and even though it didn’t give any explicit error messages during start up the viewer wouldn’t even open up on the designated port. The same command was working properly with V3.0.0 though.

hassan-essabir commented 3 years ago

Try to use -u 0 in order to run it as root : docker run --rm -u 0 -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl This works perfectly

aconital commented 3 years ago

Do we need to run it as root though? Previous versions were working fine.

hassan-essabir commented 3 years ago

It runs as root inside the container only. They are trying to bind to the port 80 as a non root user which is never gonna work unless the user is a sudoer. For me, it's a regression that needs to be fixed by maptiler. The solution I suggested is only a work around.

StephanZaat commented 3 years ago

I would suggest running the container on another port instead of the default 80. I use this in my Kubernetes manifest:

- name: tileserver
        image: maptiler/tileserver-gl
        args: ["-p", "8080", "--verbose", "-c", "/var/config/<my_config>.json"]

In Compose:

tileserver:
    image: maptiler/tileserver-gl
    ports:
      - "8080:8080"
    volumes:
      - "$PWD/data:/data"
      - "$PWD/tileserver/config:/var/config:ro"
      - "$PWD/tileserver/static:/var/static:ro"
    command: -p 8080 --verbose -c /var/config/<my_config>.json

In Docker Run: docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl -p 8080 --verbose

Running as root is not necessary then.

bonny commented 3 years ago

I had the same problem and the solution from @StephanZaat worked fine! I use tileserver gl on Dokku and I added this to my Dockerfile:

EXPOSE 8080
CMD ["-p", "8080", "--verbose"]

Basically the solution above but for a Dockerfile.

RilusMahmud commented 3 years ago

Try to use -u 0 in order to run it as root : docker run --rm -u 0 -it -v $(pwd):/data -p 8080:80 maptiler/tileserver-gl This works perfectly

Thanks for this workaround, it works just fine, but can you tell me how do I write "-u 0" in docker-compose file?

nyurik commented 3 years ago

I feel like we should introduce some param to disable the --user docker option. This way if the user wants to run all their docker images as root, they can. This might also help solve the issue some Mac users have reported with performance using shared volumes.

candux commented 2 years ago

We had the same issue in some environments. We are not completely sure when it occurs but contributing factors seem to be

acalcutt commented 1 year ago

we have changed the internal docker port from 80 to 8080, so I think this issue should be resolved.

Note, the ports in the command have changed from 8080:80 to 8080:8080 due to this change, starting in v4.2.0 docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl