You must put this in each docker-compose.yml service
restart: unless-stopped
example:
command:
sudo cat docker-compose.yml
content:
services:
nginx-80:
restart: unless-stopped
image: nginx:alpine
container_name: nginx-80
ports:
- "80:80"
volumes:
- ./nginx/nginx.dev.conf:/etc/nginx/nginx.conf:ro
- ./.htpasswd:/etc/nginx/.htpasswd
depends_on:
- openmu-startup
openmu-startup:
image: munique/openmu
container_name: openmu-startup
ports:
- "8080"
- "55901:55901"
- "55902:55902"
- "55903:55903"
- "55904:55904"
- "55905:55905"
- "55906:55906"
- "44405:44405"
- "44406:44406"
- "55980:55980"
environment:
DB_HOST: database
ASPNETCORE_URLS: http://+:8080
working_dir: /app/
volumes:
- ./.htpasswd:/etc/nginx/.htpasswd
depends_on:
- database
restart: unless-stopped
database:
image: postgres
container_name: database
environment:
POSTGRES_PASSWORD: admin
POSTGRES_DB: openmu
POSTGRES_USER: postgres
ports:
- "5432"
volumes:
- dbdata:/var/lib/postgresql #store data on volume
restart: unless-stopped
volumes:
dbdata:
then (Apply the changes):
docker compose up -d
Docker is also a systemctl service
First, check if you have a ‘docker’ service running:
sudo systemctl status docker
Enable the Docker service (that starts Docker when you restart the PC/server):
sudo systemctl enable docker
check:
sudo systemctl is-enabled docker