0

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.

Mornor
  • 3,471
  • 8
  • 31
  • 69
GihanS
  • 445
  • 2
  • 5
  • 15
  • Please, add the stacktrace. Also what is this `&& bash` supposed to do? – Mornor May 28 '18 at 10:38
  • sudo is useless, as if your Dockerfile does not have a `USER xxx` directive, you are root, and as said by Ignacio `You should provide a command that doesn't end` so you may at least add at the end `&& sleep infinity` – user2915097 May 28 '18 at 12:40

3 Answers3

3

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
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • Do i need to add above entrypoint to task definition as well or just in the dockerfile will be enough ? – GihanS May 28 '18 at 14:02
  • @user3849082 you simply replace the lines in your dockerfile with these and then rebuild your image. I'm not sure what you mean by adding to the "task definition". – BMitch May 28 '18 at 15:03
1

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

Ignacio Millán
  • 7,480
  • 1
  • 25
  • 28
0

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"]

Ashok Reddy
  • 1,060
  • 1
  • 16
  • 28