Closed MoryCorp closed 3 years ago
The shell script doesn’t not run from the volume you mount, so you need to use the full path such as > /home/steam/valheim/server.log &
Let me know if this fixes the issue!
I added /home/steam/valheim/server/valheim_server.x86_64 -name "$SERVER_NAME" -port $SERVER_PORT -world "$SERVER_WORLD" -password "$SERVER_PASSWORD" -savedir "/home/steam/valheim/data" -public 1 > /home/steam/valheim/server.log &
to my server.sh
This file is still not created inside the container
I think the problem is USER steam
in the dockerfile. That user is not allowed to write to the mounted folder.
See my pull request #7
I think the problem is
USER steam
in the dockerfile. That user is not allowed to write to the mounted folder. See my pull request #7
Same error with provided fix.
Connecting anonymously to Steam Public...Logged in OK
Waiting for user info...OK
ERROR! Failed to install app '896660' (Disk write failure)
cp: cannot create regular file '/home/steam/valheim/server/': Not a directory
/home/steam/server.sh: line 22: /home/steam/valheim/server/valheim_server.x86_64: No such file or directory
valheim inside container belongs to user 1001 :
holory@vps645530:~/apps/valheim_server$ docker exec -it valheim_server bash
steam@eadd06374343:~$ ls -l
total 20
drwxr-xr-x 1 steam steam 4096 Feb 11 15:11 Steam
-rw-r--r-- 1 root root 943 Feb 10 19:19 server.sh
drwxr-xr-x 1 steam steam 4096 Feb 11 15:10 steamcmd
drwxrwxr-x 2 1001 1001 4096 Feb 11 15:05 valheim
How did you apply the fix? You need to rebuild the container in order to make it work.
And did you pass the correct UID and GID values as ENV vars PGID and PUID?
@CanadaBry while I appreciate the time and effort you put into this container, I suggest you go and check the valheim docker at https://github.com/lloesche/valheim-server-docker
It‘s much more sophisticated and offers more functionality.
How did you apply the fix? You need to rebuild the container in order to make it work.
docker system prune -a
Dockerfile :
FROM debian:buster
# download requirements
RUN apt-get -y update && \
apt-get -y install lib32gcc1 lib32stdc++6 curl && \
apt-get clean && \
rm -rf /var/lib/{apt,dpkg,cache,log}/
ENV PUID=1000
ENV PGID=1000
# setup steam user
RUN groupadd --gid "${PGID}" -r steam
RUN useradd -u "${PUID}" -r -g "${PGID}" -m -d /home/steam -c "Valheim server user" steam
WORKDIR /home/steam
COPY server.sh .
# download steamcmd
RUN mkdir steamcmd && cd steamcmd && \
curl "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
# start steamcmd to force it to update itself
RUN ./steamcmd/steamcmd.sh +quit && \
mkdir -pv /home/steam/.steam/sdk32/ && \
ln -s /home/steam/steamcmd/linux32/steamclient.so /home/steam/.steam/sdk32/steamclient.so
# start the server main script
ENTRYPOINT ["bash", "/home/steam/server.sh"]
Server.sh
#!/bin/bash
usermod -u ${PUID} steam
groupmod -g ${PGID} steam
su -s /bin/bash -c 'id' steam
# update server's data
/home/steam/steamcmd/steamcmd.sh \
+login anonymous \
+force_install_dir /home/steam/valheim/server \
+app_update 896660 \
+exit
#Copy 64bit steamclient, since it keeps using 32bit
cp /home/steam/steamcmd/linux64/steamclient.so /home/steam/valheim/server/
#Apply default values for server if not set
SERVER_NAME=${SERVER_NAME:-My\ server}
SERVER_PORT=${SERVER_PORT:-2456}
SERVER_WORLD=${SERVER_WORLD:-Dedicated}
SERVER_PASSWORD=${SERVER_PASSWORD:-secret}
#Launch server
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970
/home/steam/valheim/server/valheim_server.x86_64 -name "$SERVER_NAME" -port $SERVER_PORT -world "$SERVER_WORLD" -password "$SERVER_PASSWORD" -savedir "/home/steam/valheim/data" -public 1 > /home/steam/valheim/server.log &
#Trap Container Stop for graceful exit
trap "kill -SIGINT $!;" SIGTERM
#Wait for server to exit
while wait $!; [ $? != 0 ]; do true; done
@CanadaBry while I appreciate the time and effort you put into this container, I suggest you go and check the valheim docker at https://github.com/lloesche/valheim-server-docker
It‘s much more sophisticated and offers more functionality.
That’s very fair. This docker was created for my personal use but wanted to share it, in case anyone wanted to try it.
The reason I haven’t merged the pull is because the synology I have access to is the 416play which doesn’t have docker installed by default. I am waiting for permission to sideload the spk.
How did you apply the fix?
You need to rebuild the container in order to make it work.
docker system prune -a
Dockerfile :
FROM debian:buster # download requirements RUN apt-get -y update && \ apt-get -y install lib32gcc1 lib32stdc++6 curl && \ apt-get clean && \ rm -rf /var/lib/{apt,dpkg,cache,log}/ ENV PUID=1000 ENV PGID=1000 # setup steam user RUN groupadd --gid "${PGID}" -r steam RUN useradd -u "${PUID}" -r -g "${PGID}" -m -d /home/steam -c "Valheim server user" steam WORKDIR /home/steam COPY server.sh . # download steamcmd RUN mkdir steamcmd && cd steamcmd && \ curl "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - # start steamcmd to force it to update itself RUN ./steamcmd/steamcmd.sh +quit && \ mkdir -pv /home/steam/.steam/sdk32/ && \ ln -s /home/steam/steamcmd/linux32/steamclient.so /home/steam/.steam/sdk32/steamclient.so # start the server main script ENTRYPOINT ["bash", "/home/steam/server.sh"]
Server.sh
#!/bin/bash usermod -u ${PUID} steam groupmod -g ${PGID} steam su -s /bin/bash -c 'id' steam # update server's data /home/steam/steamcmd/steamcmd.sh \ +login anonymous \ +force_install_dir /home/steam/valheim/server \ +app_update 896660 \ +exit #Copy 64bit steamclient, since it keeps using 32bit cp /home/steam/steamcmd/linux64/steamclient.so /home/steam/valheim/server/ #Apply default values for server if not set SERVER_NAME=${SERVER_NAME:-My\ server} SERVER_PORT=${SERVER_PORT:-2456} SERVER_WORLD=${SERVER_WORLD:-Dedicated} SERVER_PASSWORD=${SERVER_PASSWORD:-secret} #Launch server export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH export SteamAppId=892970 /home/steam/valheim/server/valheim_server.x86_64 -name "$SERVER_NAME" -port $SERVER_PORT -world "$SERVER_WORLD" -password "$SERVER_PASSWORD" -savedir "/home/steam/valheim/data" -public 1 > /home/steam/valheim/server.log & #Trap Container Stop for graceful exit trap "kill -SIGINT $!;" SIGTERM #Wait for server to exit while wait $!; [ $? != 0 ]; do true; done
Did you pass GID and UID to the Container? Maybe try the container by lloesche. (See link above)
@CanadaBry don't mean to advertise here don't get me wrong please. I have learned quite a bit from your repository about docker and steamcmd so thanks!
Btw, how much RAM does the 416 have? Valheim server uses 2,5GB on my 416play ;-)
Btw, how much RAM does the 416 have? Valheim server uses 2,5GB on my 416play ;-)
Got permission to update it/sideload. It actually only has 1GB ram it looks like LOL.
I've got it running now.
This is all it took on my end to get it to play nice. Still going to look at and test your code, but will probably have to do it later.
@CanadaBry don't mean to advertise here don't get me wrong please. I have learned quite a bit from your repository about docker and steamcmd so thanks!
I don't mind, if something works better for someone, I'drather they use it than pull their hair out. I run my docker through a dedicated box I have running Unraid, so I didn't hit most of these issues. And all my testing is done in WSL.
@MoryCorp if you still want to try my docker, just remove the USER steam
from my Dockerfile, that seemed to work no issues right away on my 416. Let me know if that helps!
How did you apply the fix?
You need to rebuild the container in order to make it work.
docker system prune -a
Dockerfile :FROM debian:buster # download requirements RUN apt-get -y update && \ apt-get -y install lib32gcc1 lib32stdc++6 curl && \ apt-get clean && \ rm -rf /var/lib/{apt,dpkg,cache,log}/ ENV PUID=1000 ENV PGID=1000 # setup steam user RUN groupadd --gid "${PGID}" -r steam RUN useradd -u "${PUID}" -r -g "${PGID}" -m -d /home/steam -c "Valheim server user" steam WORKDIR /home/steam COPY server.sh . # download steamcmd RUN mkdir steamcmd && cd steamcmd && \ curl "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf - # start steamcmd to force it to update itself RUN ./steamcmd/steamcmd.sh +quit && \ mkdir -pv /home/steam/.steam/sdk32/ && \ ln -s /home/steam/steamcmd/linux32/steamclient.so /home/steam/.steam/sdk32/steamclient.so # start the server main script ENTRYPOINT ["bash", "/home/steam/server.sh"]
Server.sh
#!/bin/bash usermod -u ${PUID} steam groupmod -g ${PGID} steam su -s /bin/bash -c 'id' steam # update server's data /home/steam/steamcmd/steamcmd.sh \ +login anonymous \ +force_install_dir /home/steam/valheim/server \ +app_update 896660 \ +exit #Copy 64bit steamclient, since it keeps using 32bit cp /home/steam/steamcmd/linux64/steamclient.so /home/steam/valheim/server/ #Apply default values for server if not set SERVER_NAME=${SERVER_NAME:-My\ server} SERVER_PORT=${SERVER_PORT:-2456} SERVER_WORLD=${SERVER_WORLD:-Dedicated} SERVER_PASSWORD=${SERVER_PASSWORD:-secret} #Launch server export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH export SteamAppId=892970 /home/steam/valheim/server/valheim_server.x86_64 -name "$SERVER_NAME" -port $SERVER_PORT -world "$SERVER_WORLD" -password "$SERVER_PASSWORD" -savedir "/home/steam/valheim/data" -public 1 > /home/steam/valheim/server.log & #Trap Container Stop for graceful exit trap "kill -SIGINT $!;" SIGTERM #Wait for server to exit while wait $!; [ $? != 0 ]; do true; done
Did you pass GID and UID to the Container? Maybe try the container by lloesche. (See link above)
@CanadaBry don't mean to advertise here don't get me wrong please. I have learned quite a bit from your repository about docker and steamcmd so thanks!
I really appreciate the time you're spending trying to help me, thanks.
Did you pass GID and UID to the Container? How should I do that with docker-compose ?
The reason why I am using this repo is because it's really light and it provides a docker-compose.yml. I don't need fancy options like backups etc.
At this point my server runs just fine and is able to save map if I chmod o+w the valheim directory.
@CanadaBry don't mean to advertise here don't get me wrong please. I have learned quite a bit from your repository about docker and steamcmd so thanks!
I don't mind, if something works better for someone, I'drather they use it than pull their hair out. I run my docker through a dedicated box I have running Unraid, so I didn't hit most of these issues. And all my testing is done in WSL.
@MoryCorp if you still want to try my docker, just remove the
USER steam
from my Dockerfile, that seemed to work no issues right away on my 416. Let me know if that helps!
Sure, I'll give it another try right now. I'll net you know in 5-10mn
I would not advise to remove USER steam. That means you'd run the server as root. Imagine someone somehow exploits the valheim server then your box might be screwed.
Btw, how much RAM does the 416 have? Valheim server uses 2,5GB on my 416play ;-)
Got permission to update it/sideload. It actually only has 1GB ram it looks like LOL.
I've got it running now.
This is all it took on my end to get it to play nice. Still going to look at and test your code, but will probably have to do it later.
This is actually not the way you should be doing it. Better create a new user with RW permissions for the two Valheim folders and only for those. That way the rest of your box is safer in case the valheim server gets compromised.
Does it work with 1GB? I mean can you play on it? :)
Well, anyway it returns an error even if I removed steam user :
valheim | ERROR! Failed to install app '896660' (Disk write failure)
valheim | cp: cannot create regular file '/home/steam/valheim/server/': Not a directory
valheim | /home/steam/server.sh: line 22: /home/steam/valheim/server/valheim_server.x86_64: No such file or directory
My files :
And inside the container :
Did you pass GID and UID to the Container?
Did you pass GID and UID to the Container?
Oh yeah sorry that's what I forgot to ask. How should I do that with docker-compose ? :)
I tried something like you did with :
RUN groupadd --gid "${PGID}" -r steam
RUN useradd -u "${PUID}" -r -g "${PGID}" -m -d /home/steam -c "Valheim server user" steam
on your host find UID and GID of user holory (or the one with RW permissions to the mounted folders) via id <username>
then add to the compose yml file under environment (say UID is 1024, GID is 100):
below - SERVER_WORLD=Dedicated
- PGID=100
- PUID=1024
I did a system prune -a just in case And still have disk failure
Can you please create a new container? Just to make sure that no existing wrong permissions are messing with you :) (or does prune do just that?)
Also try to put it below the first environment:
block - not sure if it can handle 2 environments
This is what permissions eg for server_data should be. my host user is named steam in group users
I did a system prune -a just in case And still have disk failure
Also: the volumes part looks wrong you need to have two folders mounted as volumes, so it looks something like this:
Can you please create a new container? Just to make sure that no existing wrong permissions are messing with you :) (or does prune do just that?)
I created a new container but yes that's the purpose of docker system prune -a, removes all unused images, containers etc.
Also try to put it below the first
environment:
block - not sure if it can handle 2 environments
Yeah my bad didn't even noticed there was already an environment block
Still have the same error for now
Check your volume mounts. The one you're using is wrong.
I did a system prune -a just in case And still have disk failure
Also: the volumes part looks wrong you need to have two folders mounted as volumes, so it looks something like this:
Ok so i means the provider docker-compose is wrong for now ? I'll try with your volumes then
Something like this ?
Wait. The directory setup has been changed since I last checked. In my version it still used two mounts. Yours is actually correct.
Wait. The directory setup has been changed since I last checked. In my version it still used two mounts. Yours is actually correct.
Fock :D I'm killing the container then
Try an absolute path instead of ./valheim
Try an absolute path instead of ./valheim
Ok.
valheim_again | ERROR! Failed to install app '896660' (Disk write failure) valheim_again | cp: cannot create regular file '/home/steam/valheim/server/': Not a directory valheim_again | /home/steam/server.sh: line 22: /home/steam/valheim/server/valheim_server.x86_64: No such file or directory
Damn that's the first time I am having hard times with docker
Inside the container :
Unless you have passed 1000 as PUID this is wrong and should be 1001 (as per the screenshot you sent) 1000 is default and not the value you passed as ENV vars.
Did you clone the entire branch from my fork or just pick a few lines? I built a container based on my branch and it works. Since you have another compose yml than I have, I think that you must have done something wrong applying my changes.
please paste dockerfile, compose yml and server.sh here.
Dockerfile I am using
FROM debian:buster
# download requirements
RUN apt-get -y update && \
apt-get -y install lib32gcc1 lib32stdc++6 curl && \
apt-get clean && \
rm -rf /var/lib/{apt,dpkg,cache,log}/
ENV PUID=1000
ENV PGID=1000
# setup steam user
RUN groupadd --gid "${PGID}" -r steam
RUN useradd -u "${PUID}" -r -g "${PGID}" -m -d /home/steam -c "Valheim server user" steam
WORKDIR /home/steam
RUN mkdir server_scripts
COPY server.sh server_scripts/
# download steamcmd
RUN mkdir steamcmd && cd steamcmd && \
curl "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
# start steamcmd to force it to update itself
RUN ./steamcmd/steamcmd.sh +quit && \
mkdir -pv /home/steam/.steam/sdk32/ && \
ln -s /home/steam/steamcmd/linux32/steamclient.so /home/steam/.steam/sdk32/steamclient.so
# start the server main script
ENTRYPOINT ["bash", "/home/steam/server_scripts/server.sh"]
From here, should I edit GID and PID to 1001 ?
And server.sh :
#!/bin/bash
usermod -u ${PUID} steam
groupmod -g ${PGID} steam
su -s /bin/bash -c 'id' steam
# update server's data
/home/steam/steamcmd/steamcmd.sh \
+login anonymous \
+force_install_dir /home/steam/server_data \
+app_update 896660 \
+exit
#Copy 64bit steamclient, since it keeps using 32bit
cp /home/steam/steamcmd/linux64/steamclient.so /home/steam/server_data
#Apply default values for server if not set
SERVER_NAME=${SERVER_NAME:-My\ server}
SERVER_PORT=${SERVER_PORT:-2456}
SERVER_WORLD=${SERVER_WORLD:-Dedicated}
SERVER_PASSWORD=${SERVER_PASSWORD:-secret}
#Trap Container Stop for graceful exit
trap "echo 1 > server_exit.drp;" SIGTERM
#Launch server
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970
/home/steam/server_data/valheim_server.x86_64 -name "$SERVER_NAME" -port $SERVER_PORT -world "$SERVER_WORLD" -password "$SERVER_PASSWORD" -public 1 &
#Wait for server to exit
while wait $!; [ $? != 0 ]; do true; done
Compose :
version: '3.3'
services:
valheim:
image: wilso224/valheim_dedicated_server
container_name: valheim
volumes:
- 'home/holory/apps/valheim_server/valheim:/home/steam/valheim'
ports:
- '2456:2456/udp'
- '2457:2457/udp'
- '2458:2458/udp'
environment:
- SERVER_NAME=Holory
- SERVER_PORT=2456
- SERVER_PASSWORD=morycorp
- SERVER_WORLD=Dedicated
- PGID=1001
- PUID=1001
ls -l in home/holory/apps/valheim_server please
also try /home/... instead of home/...
also try /home/... instead of home/...
Oh yeah it was already /home/ actually
Oh look, your file still uses that /home/steam/server_data bit
maybe try the mounts from my screenshots
Oh look, your file still uses that /home/steam/server_data bit
maybe try the mounts from my screenshots
All right it works. It seems that I mixed both configuration.
What should I do right now to use the current configuration without server_data ?
Edit : I'll definitly buy you a beer
Oh well, I should wait it seems that @CanadaBry is currently working on it
God damn, we were so close. I tried with the new push and disk failure again
God damn, we were so close. I tried with the new push and disk failure again
yeah current commits didn't work. reverted back to a couple days ago till I have time to go at the problem again
Sorry, I was actually playing the game for a bit - not only worrying about server stuff (which I also love playing with ;) ) So you had it working and then broke it again? ;-)
I think that if you pull my fork and edit the compose yml that it will then work again.
hey, I modiifed the server.sh by just addind
> log &
so logs of the server would be accessible through a direct text file instead of using docker logs. But it seems that this file isn't' created at all. Have you an idea ? Thanks