Prince Kumar Barnwal
Prince Kumar Barnwal

Reputation: 472

My web docker container image not running

I try to use docker for laravel project and I am using Ubuntu as a base image and laravel depedency but after docker-compose up only mysql and adminer container are running. My Dockerfile and docker-compose.yml file are below

My Dockerfile

FROM ubuntu:16.04
Run apt-get update
RUN apt-get update \
&& apt-get install -y --no-install-recommends software-properties-common
RUN apt-get update 
RUN apt-get install -y apache2 
RUN apt-get install -y php7.0 php7.0-mysql php7.0-mbstring
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN  apt-get update
RUN  apt-get install -y git zip unzip
RUN  apt-get update
COPY laravel/ /var/www/html/
COPY laravel//vhost.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /var/www/html
RUN chown -R www-data:www-data /var/www/html \
&& a2enmod rewrite

****docker yml file****

version: '2'

services:

db:
 image: mysql
 environment:
  MYSQL_ROOT_PASSWORD: mysql
ports:
   - 8086:3306

adminer:
 image: adminer
 ports:
  - 8085:8080

web:
 image: laravel
ports:
  - 8889:80
volumes:
  - .bilbayt_admin/:/var/www/html/

Upvotes: 1

Views: 171

Answers (3)

Prince Kumar Barnwal
Prince Kumar Barnwal

Reputation: 472

Now My Docker file look like this and it working

FROM ubuntu:16.04 Run apt-get update RUN apt-get update \
&& apt-get install -y --no-install-recommends software-properties-common
RUN apt-get update
RUN apt-get install
-y apache2 RUN apt-get install -y php7.0 php7.0-mysql php7.0-mbstring
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN apt-get update
RUN apt-get install -y git zip unzip
RUN apt-get update
COPY . /var/www/html
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /var/www/html
RUN chown -R www-data:www-data /var/www/html \ && a2enmod rewrite
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

Upvotes: 0

ajankuv
ajankuv

Reputation: 497

You need to add a cmd to start apache/an entry point.

Something like below at the end.

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

Upvotes: 1

bluescores
bluescores

Reputation: 4677

Looking at your Dockerfile, you need either an ENTRYPOINT or CMD, usually added as the last lines of your Dockerfile. These entries tell the image which command to run when you docker run (which is done in a roundabout way with docker-compose up).

Upvotes: 1

Related Questions