Automatic running a docker image at start up

Hi,
I have created production image and pushed to docker hub. I can run the application from the terminal using the following command.
/usr/bin/docker-compose -p torizon up -d --remove-orphans
I had copied my docker-compose.yml file to /var/sota/storage/docker-compose. Still I am not able to run the application on start up.
I am including both docker-compose.yml and tgicp.service that I had created to run the application on start up.
tgicp.service (276 Bytes)

Thanks
Pramod
docker-compose.yml (798 Bytes)

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


:handshake:

Hi Pramod,

To ensure your application runs at startup, please verify the following steps:

  1. Correct Placement of docker-compose.yml: Ensure that your docker-compose.yml file is correctly placed in the /var/sota/storage/docker-compose/ directory.

  2. Permissions: Check the permissions of the docker-compose.yml file to ensure it is readable by the system. You can set the appropriate permissions using:

    sudo chmod 644 /var/sota/storage/docker-compose/docker-compose.yml
    
  3. Systemd Services: Verify that the docker-compose systemd service is enabled and running. You can check the status with:

    systemctl status docker-compose
    

    If it is not active, you can enable and start it with:

    sudo systemctl enable docker-compose
    sudo systemctl start docker-compose
    
  4. Docker Service: Ensure that the Docker service itself is running, as it is required for the docker-compose service to function. Check the status with:

    systemctl status docker
    

    If it is not active, enable and start it with:

    sudo systemctl enable docker
    sudo systemctl start docker
    
  5. Logs: Check the logs for any errors that might indicate why the container is not starting. You can view the logs with:

    journalctl -u docker-compose
    

By following these steps, you should be able to diagnose and resolve the issue preventing your application from running at startup.

Best regards,
Toradex AI Assistant

Hi Pramod

You can just set the container to restart=always.
Then you can start the container the same as before and it should restart automatically on start up.
/usr/bin/docker-compose -p torizon up -d --remove-orphans

You don’t need an additional service for this.

docker-compose.yaml (838 Bytes)

You can check this page for more details.

Hi Allan,
Thanks for the update, I will make the necessary changes and will check if that works for me.

Thanks
Pramod