I set up the Nginx Reverse Proxy Manager by Jamie Curnow on my Raspberry Pi using docker and docker-compose.
This is the yml stack file:
---
version: '3'
services:
app:
image: 'jc21/nginx-proxy-manager:latest'
ports:
- '80:80' #HTTP Traffic
- '81:81' #Dashboard Port
- '443:443' #HTTPS Traffic
volumes:
- ./config.json:/app/config/production.json
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
db:
image: 'jc21/mariadb-aria:10.4'
environment:
MYSQL_ROOT_PASSWORD: 'npm'
MYSQL_DATABASE: 'npm'
MYSQL_USER: 'npm'
MYSQL_PASSWORD: 'npm'
volumes:
- ./data/mysql:/var/lib/mysql
(I use different passwords)
Now, I already once composed it using sudo docker-compose up -d
, however, whenever I sudo reboot
my Raspberry Pi, it doesn’t start as a service.
This is my Raspberry Pi Kernel, btw:
Linux Pi-Server 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/L
And this is my OS version:
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
The interesting part is that whenever I try to recompose it using sudo docker-compose up -d
again, I get the following output:
Starting nginx_db_1 ... done
Starting nginx_app_1 ... done
Afterwards, both Nginx and its GUI by Mr. Curnow work.
Is there a more fancy way other than running this docker-compose on startup every time?
2
Answers
You can also edit the YML file to say "
restart: always
" in the "services:
"for example like this:
I would also recommend adding your specific docker-compose as a service using this service directory:
In here simply create the file using nano or vim. The filename is not important, however, it needs to be a ".service" file, so I recommend the name "
docker-compose-app.service
"(WorkingDirectory = wherever your docker-compose file is, please change!)
All you then need to do is:
(If you've given it a different file name, use that name here)
And just to be sure:
This is a StackOverflow question which might help you answer your problem
How the restart: always policy works.
Host — docker service level
Update: the initial answer works within docker itself. If you want docker itself to also start on boot, then that’s a different story. You should be able to do that with:
VM — docker container level (nginx)
You can definitely start nginx service on boot.
The commands are self-explanatory — enable, disable, and check status of running nginx on boot:
Resources:
If this is not available at your disposal, let me know and I’ll try to find other ways and update my answer.