Docker /user/sbin/apache2ctl: not found












0















This issue is not a duplicate of “/bin/sh: 1: “apache2ctl”,: not found” in docker



This is a simple docker file I used for laravel framework in a ubuntu operating system.



version : '3'

services:
web:
container_name: ${APP_NAME}_web
build:
context: ./docker/web
ports:
- 9000:80
volumes:
- ./:/var/www/app


And this is the docker file located in docker/web



FROM php:7.2.10-apache-stretch

RUN apt-get update -yqq &&
apt-get install -y apt-utils zip unzip &&
apt-get install -y nano &&
apt-get install -y libzip-dev libpq-dev &&
a2enmod rewrite &&
docker-php-ext-install pdo_pgsql &&
docker-php-ext-install pgsql &&
docker-php-ext-configure zip --with-libzip &&
docker-php-ext-install zip &&
rm -rf /var/lib/apt/lists/*

RUN php -r "readfile('http://getcomposer.org/installer');"|php -- --install-dir=/usr/bin --filename=composer

COPY Default.conf /etc/apache2/sites-enabled/000-default.conf

WORKDIR /var/www/app

EXPOSE 80

CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


When I run this command



sudo docker-compose up


Terminal Output is this error



Starting Docker_Laravel_web ... done
Attaching to Docker_Laravel_web
Docker_Laravel_web | /bin/sh: 1: [/usr/sbin/apache2ctl,: not found
Docker_Laravel_web exited with code 127


Need some help to fix this,










share|improve this question



























    0















    This issue is not a duplicate of “/bin/sh: 1: “apache2ctl”,: not found” in docker



    This is a simple docker file I used for laravel framework in a ubuntu operating system.



    version : '3'

    services:
    web:
    container_name: ${APP_NAME}_web
    build:
    context: ./docker/web
    ports:
    - 9000:80
    volumes:
    - ./:/var/www/app


    And this is the docker file located in docker/web



    FROM php:7.2.10-apache-stretch

    RUN apt-get update -yqq &&
    apt-get install -y apt-utils zip unzip &&
    apt-get install -y nano &&
    apt-get install -y libzip-dev libpq-dev &&
    a2enmod rewrite &&
    docker-php-ext-install pdo_pgsql &&
    docker-php-ext-install pgsql &&
    docker-php-ext-configure zip --with-libzip &&
    docker-php-ext-install zip &&
    rm -rf /var/lib/apt/lists/*

    RUN php -r "readfile('http://getcomposer.org/installer');"|php -- --install-dir=/usr/bin --filename=composer

    COPY Default.conf /etc/apache2/sites-enabled/000-default.conf

    WORKDIR /var/www/app

    EXPOSE 80

    CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


    When I run this command



    sudo docker-compose up


    Terminal Output is this error



    Starting Docker_Laravel_web ... done
    Attaching to Docker_Laravel_web
    Docker_Laravel_web | /bin/sh: 1: [/usr/sbin/apache2ctl,: not found
    Docker_Laravel_web exited with code 127


    Need some help to fix this,










    share|improve this question

























      0












      0








      0








      This issue is not a duplicate of “/bin/sh: 1: “apache2ctl”,: not found” in docker



      This is a simple docker file I used for laravel framework in a ubuntu operating system.



      version : '3'

      services:
      web:
      container_name: ${APP_NAME}_web
      build:
      context: ./docker/web
      ports:
      - 9000:80
      volumes:
      - ./:/var/www/app


      And this is the docker file located in docker/web



      FROM php:7.2.10-apache-stretch

      RUN apt-get update -yqq &&
      apt-get install -y apt-utils zip unzip &&
      apt-get install -y nano &&
      apt-get install -y libzip-dev libpq-dev &&
      a2enmod rewrite &&
      docker-php-ext-install pdo_pgsql &&
      docker-php-ext-install pgsql &&
      docker-php-ext-configure zip --with-libzip &&
      docker-php-ext-install zip &&
      rm -rf /var/lib/apt/lists/*

      RUN php -r "readfile('http://getcomposer.org/installer');"|php -- --install-dir=/usr/bin --filename=composer

      COPY Default.conf /etc/apache2/sites-enabled/000-default.conf

      WORKDIR /var/www/app

      EXPOSE 80

      CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


      When I run this command



      sudo docker-compose up


      Terminal Output is this error



      Starting Docker_Laravel_web ... done
      Attaching to Docker_Laravel_web
      Docker_Laravel_web | /bin/sh: 1: [/usr/sbin/apache2ctl,: not found
      Docker_Laravel_web exited with code 127


      Need some help to fix this,










      share|improve this question














      This issue is not a duplicate of “/bin/sh: 1: “apache2ctl”,: not found” in docker



      This is a simple docker file I used for laravel framework in a ubuntu operating system.



      version : '3'

      services:
      web:
      container_name: ${APP_NAME}_web
      build:
      context: ./docker/web
      ports:
      - 9000:80
      volumes:
      - ./:/var/www/app


      And this is the docker file located in docker/web



      FROM php:7.2.10-apache-stretch

      RUN apt-get update -yqq &&
      apt-get install -y apt-utils zip unzip &&
      apt-get install -y nano &&
      apt-get install -y libzip-dev libpq-dev &&
      a2enmod rewrite &&
      docker-php-ext-install pdo_pgsql &&
      docker-php-ext-install pgsql &&
      docker-php-ext-configure zip --with-libzip &&
      docker-php-ext-install zip &&
      rm -rf /var/lib/apt/lists/*

      RUN php -r "readfile('http://getcomposer.org/installer');"|php -- --install-dir=/usr/bin --filename=composer

      COPY Default.conf /etc/apache2/sites-enabled/000-default.conf

      WORKDIR /var/www/app

      EXPOSE 80

      CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


      When I run this command



      sudo docker-compose up


      Terminal Output is this error



      Starting Docker_Laravel_web ... done
      Attaching to Docker_Laravel_web
      Docker_Laravel_web | /bin/sh: 1: [/usr/sbin/apache2ctl,: not found
      Docker_Laravel_web exited with code 127


      Need some help to fix this,







      laravel apache docker






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 17 '18 at 3:54









      Danushka herathDanushka herath

      406




      406
























          2 Answers
          2






          active

          oldest

          votes


















          2














          The Dockerfile syntax, where it has things that look like JSON lists, isn't actually JSON, and is fairly picky about its quoting. In particular, in your final line



          CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


          you must use double quotes



          CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]


          otherwise Docker interprets it as the "run a shell on this command" form, which is why you see the [ and , in your error message.






          share|improve this answer



















          • 1





            wow, This one worked for me, Thank you for the help!

            – Danushka herath
            Nov 17 '18 at 23:14



















          0














          It looks like didn't install apache application



          you should add 1 more command line in RUN



          apt-get install -y apache2 &&






          share|improve this answer
























          • No, Apache2 is available in the image

            – Danushka herath
            Nov 17 '18 at 6:39











          • maybe you can run CMD ["apache2", '-D', 'FOREGROUND']

            – RicoChen
            Nov 17 '18 at 6:51













          • Docker_Laravel_web | [Sat Nov 17 23:00:15.344434 2018] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined Docker_Laravel_web | apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

            – Danushka herath
            Nov 17 '18 at 23:01













          • I think problem is your config

            – RicoChen
            Nov 18 '18 at 6:22











          • I fixed it with answer above. Thank you very much for your help!

            – Danushka herath
            Nov 18 '18 at 12:55











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348044%2fdocker-user-sbin-apache2ctl-not-found%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          The Dockerfile syntax, where it has things that look like JSON lists, isn't actually JSON, and is fairly picky about its quoting. In particular, in your final line



          CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


          you must use double quotes



          CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]


          otherwise Docker interprets it as the "run a shell on this command" form, which is why you see the [ and , in your error message.






          share|improve this answer



















          • 1





            wow, This one worked for me, Thank you for the help!

            – Danushka herath
            Nov 17 '18 at 23:14
















          2














          The Dockerfile syntax, where it has things that look like JSON lists, isn't actually JSON, and is fairly picky about its quoting. In particular, in your final line



          CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


          you must use double quotes



          CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]


          otherwise Docker interprets it as the "run a shell on this command" form, which is why you see the [ and , in your error message.






          share|improve this answer



















          • 1





            wow, This one worked for me, Thank you for the help!

            – Danushka herath
            Nov 17 '18 at 23:14














          2












          2








          2







          The Dockerfile syntax, where it has things that look like JSON lists, isn't actually JSON, and is fairly picky about its quoting. In particular, in your final line



          CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


          you must use double quotes



          CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]


          otherwise Docker interprets it as the "run a shell on this command" form, which is why you see the [ and , in your error message.






          share|improve this answer













          The Dockerfile syntax, where it has things that look like JSON lists, isn't actually JSON, and is fairly picky about its quoting. In particular, in your final line



          CMD ['/usr/sbin/apache2ctl', '-D', 'FOREGROUND']


          you must use double quotes



          CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]


          otherwise Docker interprets it as the "run a shell on this command" form, which is why you see the [ and , in your error message.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 17 '18 at 11:41









          David MazeDavid Maze

          12.9k31225




          12.9k31225








          • 1





            wow, This one worked for me, Thank you for the help!

            – Danushka herath
            Nov 17 '18 at 23:14














          • 1





            wow, This one worked for me, Thank you for the help!

            – Danushka herath
            Nov 17 '18 at 23:14








          1




          1





          wow, This one worked for me, Thank you for the help!

          – Danushka herath
          Nov 17 '18 at 23:14





          wow, This one worked for me, Thank you for the help!

          – Danushka herath
          Nov 17 '18 at 23:14













          0














          It looks like didn't install apache application



          you should add 1 more command line in RUN



          apt-get install -y apache2 &&






          share|improve this answer
























          • No, Apache2 is available in the image

            – Danushka herath
            Nov 17 '18 at 6:39











          • maybe you can run CMD ["apache2", '-D', 'FOREGROUND']

            – RicoChen
            Nov 17 '18 at 6:51













          • Docker_Laravel_web | [Sat Nov 17 23:00:15.344434 2018] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined Docker_Laravel_web | apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

            – Danushka herath
            Nov 17 '18 at 23:01













          • I think problem is your config

            – RicoChen
            Nov 18 '18 at 6:22











          • I fixed it with answer above. Thank you very much for your help!

            – Danushka herath
            Nov 18 '18 at 12:55
















          0














          It looks like didn't install apache application



          you should add 1 more command line in RUN



          apt-get install -y apache2 &&






          share|improve this answer
























          • No, Apache2 is available in the image

            – Danushka herath
            Nov 17 '18 at 6:39











          • maybe you can run CMD ["apache2", '-D', 'FOREGROUND']

            – RicoChen
            Nov 17 '18 at 6:51













          • Docker_Laravel_web | [Sat Nov 17 23:00:15.344434 2018] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined Docker_Laravel_web | apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

            – Danushka herath
            Nov 17 '18 at 23:01













          • I think problem is your config

            – RicoChen
            Nov 18 '18 at 6:22











          • I fixed it with answer above. Thank you very much for your help!

            – Danushka herath
            Nov 18 '18 at 12:55














          0












          0








          0







          It looks like didn't install apache application



          you should add 1 more command line in RUN



          apt-get install -y apache2 &&






          share|improve this answer













          It looks like didn't install apache application



          you should add 1 more command line in RUN



          apt-get install -y apache2 &&







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 17 '18 at 5:49









          RicoChenRicoChen

          111




          111













          • No, Apache2 is available in the image

            – Danushka herath
            Nov 17 '18 at 6:39











          • maybe you can run CMD ["apache2", '-D', 'FOREGROUND']

            – RicoChen
            Nov 17 '18 at 6:51













          • Docker_Laravel_web | [Sat Nov 17 23:00:15.344434 2018] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined Docker_Laravel_web | apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

            – Danushka herath
            Nov 17 '18 at 23:01













          • I think problem is your config

            – RicoChen
            Nov 18 '18 at 6:22











          • I fixed it with answer above. Thank you very much for your help!

            – Danushka herath
            Nov 18 '18 at 12:55



















          • No, Apache2 is available in the image

            – Danushka herath
            Nov 17 '18 at 6:39











          • maybe you can run CMD ["apache2", '-D', 'FOREGROUND']

            – RicoChen
            Nov 17 '18 at 6:51













          • Docker_Laravel_web | [Sat Nov 17 23:00:15.344434 2018] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined Docker_Laravel_web | apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

            – Danushka herath
            Nov 17 '18 at 23:01













          • I think problem is your config

            – RicoChen
            Nov 18 '18 at 6:22











          • I fixed it with answer above. Thank you very much for your help!

            – Danushka herath
            Nov 18 '18 at 12:55

















          No, Apache2 is available in the image

          – Danushka herath
          Nov 17 '18 at 6:39





          No, Apache2 is available in the image

          – Danushka herath
          Nov 17 '18 at 6:39













          maybe you can run CMD ["apache2", '-D', 'FOREGROUND']

          – RicoChen
          Nov 17 '18 at 6:51







          maybe you can run CMD ["apache2", '-D', 'FOREGROUND']

          – RicoChen
          Nov 17 '18 at 6:51















          Docker_Laravel_web | [Sat Nov 17 23:00:15.344434 2018] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined Docker_Laravel_web | apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

          – Danushka herath
          Nov 17 '18 at 23:01







          Docker_Laravel_web | [Sat Nov 17 23:00:15.344434 2018] [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined Docker_Laravel_web | apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

          – Danushka herath
          Nov 17 '18 at 23:01















          I think problem is your config

          – RicoChen
          Nov 18 '18 at 6:22





          I think problem is your config

          – RicoChen
          Nov 18 '18 at 6:22













          I fixed it with answer above. Thank you very much for your help!

          – Danushka herath
          Nov 18 '18 at 12:55





          I fixed it with answer above. Thank you very much for your help!

          – Danushka herath
          Nov 18 '18 at 12:55


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348044%2fdocker-user-sbin-apache2ctl-not-found%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini