I made this unit file.
[Unit]
Description=myservice
Requires=docker.service
After=docker.service
[Service]
Restart=always
# Remove old containers, images and volumes
ExecStartPre=/usr/local/bin/docker-compose -f my.yml down -v
ExecStartPre=/usr/local/bin/docker-compose -f my.yml rm -v
ExecStartPre=-/bin/bash -c 'docker volume rm $(docker volume ls -q)'
ExecStartPre=-/bin/bash -c 'docker rmi $(docker images | grep "<none>" | awk \'{print $3}\')'
ExecStartPre=-/bin/bash -c 'docker rm -v $(docker ps -aq)'
# Compose up
ExecStart=/usr/local/bin/docker-compose -f my.yml up
# Compose down, remove containers and volumes
ExecStop=/usr/local/bin/docker-compose -f my.yml down -v
[Install]
WantedBy=multi-user.target
Before running this file, I create the migration like this:
docker-compose -f my.yml run --rm django python manage.py migrate
But, after rebooting the OS, I need to restart the migration, because they are not detected. What can be wrong?