dnwjn / palworld-server-watcher

Simple watcher to be used together with thijsvanloef/palworld-server-docker.
MIT License
16 stars 0 forks source link

How to use correctly #3

Closed Biubush closed 6 months ago

Biubush commented 6 months ago

I'm not quite sure how to use this script. I thought it was about spinning up another container to monitor the palworld-server container I've already deployed. However, when I tried 'docker-compose up,' I encountered the following error:

[+] Running 0/0
⠋ Container palworld-server Creating 0.0s
Error response from daemon: Conflict. The container name "/palworld-server" is already in use by container "0596521c086b09f6c32b2ca9b9ae10210797a0993d6b3dcde1e1780ad5dcb277". You have to remove (or rename) that container to be able to reuse that name.

So, does it mean it's actually trying to recreate a container named palworld-server for me? If so, how can I specify parameters like --env-file for this container?

屏幕截图 2024-02-27 220501

wkelton commented 6 months ago

Can you post your docker compose file?

Essentially you have to do everything in the "How to use" section of the README

dnwjn commented 6 months ago

Hi @Biubush! As @wkelton asked, could you share your Docker Compose file? It seems that you've defined the same container name multiple times, but I would only be able to research that theory if I know your setup.

Biubush commented 6 months ago

Hi @Biubush! As @wkelton asked, could you share your Docker Compose file? It seems that you've defined the same container name multiple times, but I would only be able to research that theory if I know your setup.

Sure! Since I modified the internal and external port parameters of the already existing palworld-server, I made a little change. Here is my Docker Compose file:

version: "3"

services:
   server:
      image: thijsvanloef/palworld-server-docker:latest
      container_name: palworld-server
      network_mode: service:watcher                   # This is important!
      # Continue with your own configuration

   watcher:
      image: dnwjn/palworld-server-watcher:latest
      container_name: palworld-watcher
      environment:
         - CONTAINER_NAME=palworld-server             # The name of the server container
         - GAME_PORT=65347                             # The same value as `PORT` in the server container
         - QUERY_PORT=38225                           # The same value as `QUERY_PORT` in the server container
         - LOOP_SLEEP_SECONDS=30                      # How often to check the server status
         - CONNECT_GRACE_SECONDS=60                   # After starting the server, how long to wait before continuing the loop
      ports:
        - 65347:65347/udp                               # The same value as `GAME_PORT`
        - 38225:38225/udp                           # Enable to show up in the server list
      volumes:
         - /var/run/docker.sock:/var/run/docker.sock  # This could be different depending on the operating system
dnwjn commented 6 months ago

@Biubush Thanks for providing your setup! Using your config I'm unable to reproduce your issue:

image

This makes me believe that you already have a Docker container running for the server, either via another Docker Compose config or directly through docker run. Can you make sure this is not the case?

If you do have your server running a different way it's important that you migrate it to the same Docker Compose file so it can use the same network as the watcher (needed for the watcher starting/stopping the server, as well as routing the traffic).