0

I want to run shell.sh in Ubuntu docker with apache and some services. This is my shell:

#!/bin/bash
/var/www/cron350.sh> /dev/null 2>&1 &

So in docker-compose.yml I add this command:

command: bash -c "/var/www/shell.sh && service php7.1-fpm start && service cron start && /usr/sbin/apache2ctl -D FOREGROUND"

I run "docker-compose up -d", however it doesn't work in the first time- everything is OK but the shell doesn't run. When I try to run "docker-compose up -d" again, the shell runs. Can you tell me why this happens? How can I fix it?

I'm so sorry because my English is not good.

  • Can you start it without `-d` and provide any errors from the log. – yamenk Dec 12 '17 at 08:06
  • Thanks for your supporting. It doesn't work in the first time because cron350.sh connect to mysql container, however mysql container hasn't initialized at that time. I edited the shell and it worked. – NickNguyen Dec 12 '17 at 20:32

1 Answers1

0

Possible duplicate of : Using Docker-Compose, how to execute multiple commands

To build docker container, docker-compose up --build

To start that, docker start -t [CONTAINER]

To execute an interactive bash shell on the container, docker exec -it [CONTAINER_ID] bash

Hemangi Pithava
  • 138
  • 1
  • 7