How to start below services in docker Entrypoint

4.6k Views Asked by At

I want to start below services when container is running.

sudo service celeryd start
sudo service celerybeat start 
service php7.0-fpm start 
service rsyslog start 

Current below command is not working AWS ECS. And throwing some errors.

ENTRYPOINT sudo service celeryd start 
&& sudo service celerybeat start 
&& service php7.0-fpm start 
&& service rsyslog start && bash

Please advise me how to do it

Thanks in advance.

3

There are 3 best solutions below

2
On BEST ANSWER

I don't recommend the overall design since you are running multiple apps inside a single container. You have no error handling or feedback if any one service fails to start. That said, fixing your current problem can be done by using a command that won't exit when there is no input.

ENTRYPOINT service celeryd start \
 && service celerybeat start \
 && service php7.0-fpm start \
 && service rsyslog start \
 && tail -f /dev/null
4
On

The commands you're trying to execute as entrypoint are a bash expression, so they must be executed inside a bash terminal:

ENTRYPOINT ["/bin/bash", "-c", "sudo service celeryd start && sudo service celerybeat start && sudo service php7.0-fpm start && sudo service rsyslog start && tail -f /dev/null"]

Furthermore, your last command is bash so the container will end right after executing the entrypoint. You should provide a command that doesn't end

0
On

put all commands start.sh file and give execute permission, Copy that files to docker image while building docker image

write docker file below CMD ["./start.sh"]