Closed MoryCorp closed 3 years ago
Try taking my current repo (the one I just reverted to) and using this Dockerfile
.
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=1001
ENV PGID=1001
# setup steam user # 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
USER 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"]
In docker-compose.yml
replace the line
image: wilso224/valheim_dedicated_server
with
image: valheim
Then run this in the directory:
mkdir valheim/
docker build . -t valheim
docker-compose up -d
This should make the user in the container have the same UID as your host user (assuming its still 1001).
Trying
Edit : it seems to work. Server started with my imported map.
Inside the container :
That's the first time "valheim" directory is created by the right user
Glad you have it working! :)
I guess this kinda means that my #7 is working :P
Glad it’s finally working!
Glad you have it working! :)
I guess this kinda means that my #7 is working :P
Yeah, I found one issue with it when I merged it. The server.sh script was still running as root because su line only ran id
as steam. The rest of the script was still running with root.
From some looking around, there wasn’t any nice (read: non hacky) way to change user mid shell script.
So the only option really is to build the image with the correct uid/gid you want.
Many thanks for the help. So for next updates of the repo I'll have to change my user id to 1000 or build image myself ?
Many thanks for the help. So for next updates of the repo I'll have to change my user id to 1000 or build image myself ?
Yeah, you’ll likely have to keep building it yourself with 1001. I’ll update the dockerfile in a bit to match the one I gave you here.
Haven’t had to address this sort of issue before, so I have to assess if this is the way I want to handle it or if I can find a better alternative
Why would @MoryCorp need to have UID&GID hard coded in the dockerfile? Can't he pass the values using the ENV variables? After all the dockerfile then uses those PGID and PUID variables.
Why would @MoryCorp need to have UID&GID hard coded in the dockerfile? Can't he pass the values using the ENV variables? After all the dockerfile then uses those PGID and PUID variables.
Yeah, as long as the docker-compose is building the image as well as running it. Was busy for the last week, sorry for the late reply.
Opening a new issue as all files changed.
Inside valheim directory
docker-compose.yml :
Dockerfile :
server.sh
Please tell me what I am doing wrong @CanadaBry @InB4DevOps