Run your own Mastodon server on localhost
I want to play around with #Mastodon API. So I thought about an environment I could use for it.
I had these options:
- Create an account at an arbitrary server and pollute this server with my test messages. Uhhh, don't do that!!! The owner of the server will hate you and that for good reasons.
- Find a server in the world that was setup especially for this purpose. I have not found one and didn't want to look for it very long.
- Create a “fake” account at my server (saptodon.org) and use this. No good idea. I would spam the local timeline with my test posts. This would disturb the other users of saptodon.
- Setup a server on my own PC and use it. Sounds good but also like a lot of work.
I decided to setup a server on my PC to access it via localhost. Cause I didn't want to install the software and set several environment variables at my PC I went to Dockerhub and searched for an image. I found an image from VMWARE that was easy to install (no config at all). There is also another promising image from linuxserver.io but this needs some additional services (e.g. postgresql database) that needs to be setup and linked to your mastodon container by yourself.
The installation was very easy. I just downloaded a docker-compose.yaml file and ran it.
curl -sSL https://raw.githubusercontent.com/bitnami/containers/main/bitnami/mastodon/docker-compose.yml > docker-compose.yml
docker-compose up -d
Note: If you, unlike me, want to save some time read the docker-hub documentation of the bitnami image completely till the end. Otherwise you will wonder and search the internet for the default usernames and passwords :–).