restic / rest-server

Rest Server is a high performance HTTP server that implements restic's REST backend API.
BSD 2-Clause "Simplified" License
899 stars 139 forks source link

Cannot change the listen port on docker container #286

Closed alphadijkstra closed 1 month ago

alphadijkstra commented 1 month ago

Output of rest-server --version

docker 0384c3e2599f

How did you run rest-server exactly?

version: "3.2"
services:
  resticrestserver:
    image: restic/rest-server:latest
    container_name: resticrestserver
    volumes:
      - /mnt/cache/docker/config/restic_restserver/data:/data
    ports:
    - "6333:6333" #Restic REST listen port server
    environment:
      DISABLE_AUTHENTICATION: 1
      OPTIONS: --listen ":6333"
    restart: always

What backend/server/service did you use to store the repository?

N.A.

Expected behavior

Rest server should work on listen port 6333

Actual behavior

resticrestserver   | Data directory: /data
resticrestserver   | Authentication disabled
resticrestserver   | Private repositories disabled
resticrestserver   | error: unable to listen: listen on ':6333' failed: listen tcp: address tcp/6333': unknown port

Steps to reproduce the behavior

Using the above docker-compose.yml.

Do you have any idea what may have caused this?

No

Do you have an idea how to solve the issue?

No

Did rest-server help you today? Did it make you happy in any way?

I am really intrigued by rest server, but cannot get it to work in this way. I need to use a different listen port. Other than 8000.

tdolega commented 1 month ago

Why not just use Docker port mapping like "8000:6333"?

alphadijkstra commented 1 month ago

Because another docker container on the same host already uses that port.

Eventually I changed the port of that other container and used the default port for the rest server.

More of a workaround than a fix to the solution.

tdolega commented 1 month ago

You can set

ports:
    - "8000:6333"

or

ports:
    - "8000:6334"

or whatever. It will not interfere with other docker containers.

MichaelEischer commented 1 month ago

Why not just use Docker port mapping like "8000:6333"?

Because another docker container on the same host already uses that port.

That doesn't make sense. According to your docker compose file you don't use the host network option, thus every container can listen on it's own private set of ports.

ports:

  • "8000:6334"

The syntax is HOST_PORT:CONTAINER_PORT. Thus, 6333:8000 would be correct here along with removing the --listen option.

Running ../rest-server/rest-server --listen :12345 --path testrepo --no-auth works for me. The problem are the quotes in OPTIONS: --listen ":6333" those are incorrect. That is you tell rest-server to use address ":6333" (not :6333), which is wrong.