ETA: This is being done on a Raspberry Pi 4 running 64-bit Raspbian using an external SSD as storage.
I am following the instructions here: https://github.com/LemmyNet/lemmy-docs/blob/4249465e9960cad97245aa03b3ad4c758ff945c7/src/en/administration/install_docker.md
Please note that I have only used docker a few times in the past and have always failed so that could be a contributing factor.
My goal for the moment is just to have the instance on localhost so I can play around with it before deciding if running my own instance is something I have the time for.
Here are the steps I have taken so far and the result:
- apt install docker-compose docker.io
- mkdir /lemmy
- cd /lemmy
- wget https://raw.githubusercontent.com/LemmyNet/lemmy/release/v0.17/docker/prod/docker-compose.yml
- wget https://raw.githubusercontent.com/LemmyNet/lemmy/release/v0.17/docker/prod/lemmy.hjson
- mkdir -p volumes/pictrs
- sudo chown -R 991:991 volumes/pictrs
- change db pswd in docker-compose.yml
- created nginx.conf (in root of lemmy folder) with config info on the above-linked page
- edited lemmy.hjson and changed admin username, admin pswd, site name, hostname (to “localhost,” also tried “127.0.0.1”), set postgres pswd to db pswd I put into docker-compose.yml
- then i run docker-compose up -d and get the following message:
`WARNING: The Qa variable is not set. Defaulting to a blank string. WARNING: The k variable is not set. Defaulting to a blank string. ERROR: Couldn’t connect to Docker daemon at http+docker://localhost - is it running?
If it’s at a non-standard location, specify the URL with the DOCKER_HOST environment variable. `
I imagine I’m doing a lot of things wrong. I would be extremely appreciative for any help anybody can provide.
Are you able to post logs from both the
lemmy
container and thelemmy-ui
container? That might shed some light as to which one is failing.$ sudo docker logs lemmy $ sudo docker logs lemmy-ui
You may need to run
sudo docker container ls
in order to find the actual container name for the two, as the default docker-compose doesn’t specify their names, so they’ll get randomly generated.(I’m assuming the error you’re seeing from
docker compose up -d
is fromlemmy-ui
, and something else is failing or preventing the backend from starting, but that’s just a guess)It looks like no containers have even been created:
[redacted]@[redacted]:~/Downloads/lemmy $ sudo docker logs lemmy Error: No such container: lemmy [redacted]@[redacted]:~/Downloads/lemmy $ sudo docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [redacted]@[redacted]:~/Downloads/lemmy $
I guess it didn’t get far enough in the process to make them?
Hmm. Well I literally just setup a Pi running a Lemmy instance last week. I can walk you through the steps that I took…
-
Ubuntu Server using https://www.raspberrypi.com/software/. Raspbian should also work with these steps, but I just happened to use Ubuntu Server. So feel free to skip this step.
-
Install Docker via these instructions: https://docs.docker.com/engine/install/ubuntu/. If you used these steps to install Docker prior, feel free to skip, but if you just did
apt-get install...
you may need to revisit that page. -
created a
lemmy
folder somewhere on my machine. For the sake of argument, I’m going to assume/docker/lemmy
for now.
3a) Create the
volumes
andpictrs
folders and chown them as described in original documentation: https://join-lemmy.org/docs/en/administration/install_docker.html-
Copy the
docker-compose.yml
file as described in the documentation as well as the lemmy.hjson. I placed the docker-compose in/docker
and thelemmy.hjson
in/docker/lemmy
. -
Edit the
docker-compose.yml
so that you use the latest pre-build images instead of building from source. To do that you’ll want to remove the lines that look like this:
build: context: ../ dockerfile: docker/Dockerfile
and instead replace them with:
image: dessalines/lemmy:<tag>
but before we do that we need to determine the latest tags that are available to the Pi. You can look here: https://hub.docker.com/r/dessalines/lemmy/tags and here: https://hub.docker.com/r/dessalines/lemmy-ui/tags. For the Pi though the latest versions available are:
0.17.3-linux-arm64
for both the backend and the UI.- Now you should be able to edit the lemmy.hjson / docker-compose and the nginx.conf files to match your environment (i.e. set the passwords, site-name, etc…).
P.S. I did lookup the error you got and it seems to be related to Nginx. So if above steps don’t work, you may need to paste your
nginx.conf
file.Okay so here are the contents of the nginx.conf file:
worker_processes 1; events { worker_connections 1024; } http { upstream lemmy { # this needs to map to the lemmy (server) docker service hostname server "lemmy:8536"; } upstream lemmy-ui { # this needs to map to the lemmy-ui docker service hostname server "lemmy-ui:1234"; } server { # this is the port inside docker, not the public one yet listen 80; # change if needed, this is facing the public web server_name localhost; server_tokens off; gzip on; gzip_types text/css application/javascript image/svg+xml; gzip_vary on; # Upload limit, relevant for pictrs client_max_body_size 20M; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; # frontend general requests location / { # distinguish between ui requests and backend # don't change lemmy-ui or lemmy here, they refer to the upstream definitions on top set $proxpass "http://lemmy-ui"; if ($http_accept = "application/activity+json") { set $proxpass "http://lemmy"; } if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") { set $proxpass "http://lemmy"; } if ($request_method = POST) { set $proxpass "http://lemmy"; } proxy_pass $proxpass; rewrite ^(.+)/+$ $1 permanent; # Send actual client IP upstream proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } # backend location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known) { proxy_pass "http://lemmy"; # proxy common stuff proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # Send actual client IP upstream proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
}
All of this looks fine. But incase anyone else has any ideas, here’s the results I found looking up the original error: https://github.com/docker/compose/issues/4189
Okay so I don’t see
build: context: ../ dockerfile: docker/Dockerfile
in the docker compose file anywhere. Where should I then place
image: dessalines/lemmy:<tag>
?
https://raw.githubusercontent.com/LemmyNet/lemmy/main/docker/docker-compose.yml
... services: proxy: ... lemmy: # image: dessalines/lemmy:dev # use this to build your local lemmy server image for development # run docker compose up --build build: context: ../ dockerfile: docker/Dockerfile # args: # RUST_RELEASE_MODE: release # this hostname is used in nginx reverse proxy and also for lemmy ui to connect to the backend, do not change hostname: lemmy
Just copied this from the above URL. But just under
lemmy:
there’s a few comments and the reference to the build section. You’ll want to remove those lines. and just have:lemmy: image: dessalines/lemmy:0.17.3-linux-arm64 ...
You’ll need to do the same thing for
lemmy-ui
, but it’s build section is already commented out but the default compose is using an incorrect tag for the Pi.See below:
... lemmy-ui: image: dessalines/lemmy-ui:0.17.1 # use this to build your local lemmy ui image for development # run docker compose up --build # assuming lemmy-ui is cloned besides lemmy directory # build: # context: ../../lemmy-ui # dockerfile: dev.dockerfile ...
so for it, you just want to change it to:
lemmy-ui: image: dessalines/lemmy-ui:0.17.3-linux-arm64 ...
Got it, thank you!
Thank you for this! I am working on it now. Having issues with installing docker as it seems like their repo for Raspbian is actually empty… I suppose I can just tell it to use an Ubuntu repo and put in the most recent Ubuntu version name so it pulls from there. I’ll let you know how it all goes.
-
Does your database password contain $Qa and/or $k? It’ll interpret those as environment variables if not escaped properly.
The docker daemon not running is a bit weird, usually docker-compose shouldn’t be trying to connect to the daemon via http, are you using sudo?