qdm12 / teamspeak-server-alpine

Minimalist Teamspeak 3 server Docker container
MIT License
9 stars 5 forks source link

Deploying the ARMv7 container on Raspberry Pi #1

Closed Th0masL closed 5 years ago

Th0masL commented 5 years ago

Hey !

Thanks for your work on creating a teamspeak server compatible for ARM architecture.

I want to run my teamspeak server on a Raspberry Pi 3B, running Raspbian Linux 9 (stretch), in docker.

I followed your tutorial, but I'm experiencing some problems.

First, there's minor a typo under the 2. CLICK IF YOU HAVE AN ARM DEVICE section, you forgot to set the proper repo name, as it's still written qmcgaw/REPONAME_DOCKER, so I replaced it by qmcgaw/teamspeak3-alpine.

Once this typo fixed, it's building correctly the ARM image :

root@raspberrypi:/# docker images REPOSITORY TAG IMAGE ID CREATED SIZE qmcgaw/teamspeak3-alpine latest 2b39f9e31d34 27 minutes ago 19.3MB arm32v7/alpine 3.10 fff333dc0cce 4 weeks ago 3.74MB

But when I try to start the container, using the following command, I get an error.

Container startup command :

docker run --detach --volume "/mnt/teamspeak/data:/teamspeak/data" --volume "/mnt/teamspeak/logs:/teamspeak/logs" -p 9987:9987/udp -p 10011:10011/tcp -p 30033:30033/tcp qmcgaw/teamspeak3-alpine license_accepted=1

The error I get is the following :

root@raspberrypi:/# docker logs faa31fe64956 /teamspeak/data/ts3server.sqlitedb is not readable, please 'chown 1000 data/ts3server.sqlitedb && chmod 700 data/ts3server.sqlitedb' on your host (status 1)

I have created the expected dirs (data and logs) in thefolder /mnt/teamspeak, with 777 perms for now, since I was trying to troubleshoot, but it's not helping.

Folder permissions :

root@raspberrypi:/# ls -al /mnt/teamspeak/ total 16 drwxrwxrwx 4 root root 4096 Sep 21 21:07 . drwxr-xr-x 3 root root 4096 Apr 24 00:27 .. drwxrwxrwx 2 root root 4096 Sep 21 21:07 data drwxrwxrwx 2 root root 4096 Sep 21 21:07 logs

Do you have an idea what could be the problem ?

Thanks

Thomas

qdm12 commented 5 years ago

Hi Thomas,

Thanks for reporting the issue. Maybe try chown -R 1000 /mnt/teamspeak, so that it's owned by user ID 1000 and not root (just for security reasons so if someone hacks your container they don't have root access to your host). I'll test it tomorrow and see if it works out.

And thanks for the readme mistake, I'll fix it too.

Let me know how it goes.

Th0masL commented 5 years ago

Hey,

Thanks for your quick answer.

Did some more troubleshooting, to confirm the behavior.

I'm running docker as root, and I don't have any user/group with such 1000 UID/GID.

root@raspberrypi:/# grep ":1000:" /etc/passwd root@raspberrypi:/# root@raspberrypi:/# grep ":1000:" /etc/group root@raspberrypi:/#

I've also tried to create the data and logs folder in the current working directory, from where I trigger the docker run command, but it's not helping, the error is the same.

Thomas

qdm12 commented 5 years ago

Hi,

You don't need a user with ID 1000. The Docker container will drop root privileges to user with ID 1000 and it doesn't have to exist on your host nor in the container actually.

So on your host, just run

mkdir -p data logs
chown 1000 data logs
chmod 700 data logs

Command ls -al will show it's now owned by 1000 instead of root, which is what we want 😄

Alternatively, you might be able to run the container as root by adding --user="root" or user: "root" for docker compose, but this adds a security risk (by the way any container running as root causes this same risk).

Feel free to close the issue if it works, or comment if it does not!

I have also fixed the readme just now, thanks!

Th0masL commented 5 years ago

I've just tried, and it's not fixing the problem.

Giving full access to /mnt folder and sub-folders :

root@raspberrypi:/# chmod 777 -R /mnt

Verifying the access :

root@raspberrypi:/# ls -al / | grep mnt drwxrwxrwx 3 root root 4096 Apr 24 00:27 mnt

Giving ownership to 1000:1000 on the teamspeak folders and sub-folders :

root@raspberrypi:/# chown 1000:1000 -R /mnt/teamspeak

Verifying the ownership :

root@raspberrypi:/# ls -al /mnt drwxrwxrwx 4 1000 1000 4096 Sep 21 21:07 teamspeak root@raspberrypi:/# ls -al /mnt/teamspeak/ drwxrwxrwx 2 1000 1000 4096 Sep 21 21:07 data drwxrwxrwx 2 1000 1000 4096 Sep 21 21:07 logs

Running container (keeps restarting as I've started it with the command --restart unless-stopped and it's failing) :

root@raspberrypi:/scripts/containers/teamspeak# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4162d4f0dc50 qmcgaw/teamspeak3-alpine "/teamspeak/entrypoi…" 13 seconds ago Restarting (1) 1 second ago cocky_borg

Showing logs :

root@raspberrypi:/scripts/containers/teamspeak# docker logs 4162d4f0dc50 /teamspeak/data/ts3server.sqlitedb is not readable, please 'chown 1000 data/ts3server.sqlitedb && chmod 700 data/ts3server.sqlitedb' on your host (status 1)

I have the feeling that it's the permissions that are inside the Docker container that are not valid, not the permissions on the shared volume.

PS : I also tried to give only 700 rights instead of 777, but ofc it's not changing anything

Can you tell me what is the local path that you are using on your Docker server for the folders data and logs, so I can try with this same path, to see if it's helping ?

qdm12 commented 5 years ago

Hi @Th0masL

My deepest apologies, it was my fault 😞 The script would only try to create the necessary files when they already existed, I fixed it, so it will create the files when they don't exist (which is your case).

You will still have to run chmod 700 /mnt/teamspeak/data/ts3server.sqlitedb after running the container once, but it will work on the second run.

Let me know how it goes, and sorry for the confusion.