how to start an app within container automatically using docker-compose.yml

I often have to recreate my container using “docker-compose up” command. The problem I have is every time after I recreate the container, I have to go to terminal within the container to run command like “sudo service xx start” to start the app. Is there provision for me to include that sudo command within my docker-compose file? so that I can avoid this extra step.

I tried adding following line within docker-compose but does not work “command: sudo service..”

Any help is appreciated. Thank you.

Source: StackOverflow