I have lubuntu 21.04 on my old PC. All is up to date. I install docker and docker-compose:
sudo apt install docker docker-compose
sudo systemctl enable --now docker
After that in home dir create folder web with my project. The structure of folder ~/web below:
.
├── docker-compose.yml
├── dockerfiles
│ ├── lg4
│ ├── test
│ └── test2
└── www
├── lg4
├── test
└── test2
All services have restart derictive in docker-compose.yml:
version: '3.7'
volumes:
mysql-volume:
networks:
app-shared:
driver: bridge
web_app-shared:
external: true
services:
php-httpd-lg4:
restart: always
build:
args:
user: lg4
uid: 1000
context: ./dockerfiles/lg4/
ports:
- 80:80
volumes:
- "./www/lg4:/var/www/html"
links:
- database
networks:
- app-shared
- web_app-shared
php-httpd-test:
restart: always
build:
args:
user: test
uid: 1000
context: ./dockerfiles/test/
ports:
- 82:80
volumes:
- "./www/test:/var/www/html"
links:
- database
networks:
- app-shared
- web_app-shared
php-httpd-test2:
restart: always
build:
args:
user: test
uid: 1000
context: ./dockerfiles/test2/
ports:
- 81:80
volumes:
- "./www/test2:/var/www/html"
links:
- database
networks:
- app-shared
- web_app-shared
database:
restart: always
image: mysql:5.7
restart: always
volumes:
- mysql-volume:/var/lib/mysql
ports:
- 3306:3306
networks:
- app-shared
- web_app-shared
environment:
TZ: "Europe/Moskow"
MYSQL_ALLOW_EMPTY_PASSWORD: "no"
MYSQL_ROOT_PASSWORD: "root"
MYSQL_USER: 'admin'
MYSQL_PASSWORD: 'admin'
MYSQL_DATABASE: 'lg4'
phpmyadmin:
restart: always
image: phpmyadmin/phpmyadmin
links:
- 'database:db'
ports:
- 8081:80
environment:
UPLOAD_LIMIT: 300M
networks:
- app-shared
- web_app-shared
All works fine when I run comand sudo docker-compose up -d from ~/web dir. But how can I start all this automatically on startup system without typing any commands in terminal every time?