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,
2
Answers
It looks like didn’t install apache application
you should add 1 more command line in RUN
apt-get install -y apache2 &&
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
you must use double quotes
otherwise Docker interprets it as the “run a shell on this command” form, which is why you see the
[
and,
in your error message.