0

I have create Dockerfile for setup LEMP then add entrypoint to one script to install magento 2, while create container.

After Create Container our entry point script to call to install magento2, after install magento 2 docker container goes to shutdown. I restart the container, its not started. I check docker logs container_name . no logs throw,

my doubt, magento 2 have any restriction, to install magento 2 while create a container. or any other issue.

Note: if magento2 not installed in this container, container works fine.

Update:

DockerFile:

FROM debian:jessie

USER root

# install editor
RUN apt-get update  && apt-get install -y vim openssh-server sudo  net-tools cron curl wget tar sudo apt-utils monit supervisor git && \
     apt-get clean && apt-get update && apt-get install -y nodejs &&\
     ln -s /usr/bin/nodejs /usr/bin/node  &&\
     apt-get install -y npm  &&\
     npm update -g npm && npm install -g grunt-cli && npm install -g gulp &&\
     echo "root:test" | chpasswd &&\
     sed -i 's/prohibit-password/yes/' /etc/ssh/sshd_config &&\
     ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa &&\
     echo "StrictHostKeyChecking=no" >> /etc/ssh/ssh_config


# install nginx

RUN apt-get update && apt-get install nginx -y

# install php

RUN echo "deb http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list
RUN wget https://www.dotdeb.org/dotdeb.gpg
RUN apt-key add dotdeb.gpg
RUN apt-get update && apt-get install -y \
    php7.0 \
    libapache2-mod-php7.0 \
    php7.0  \
    php7.0-common \
    php7.0-gd \
    php7.0-mysql \
    php7.0-mcrypt \
    php7.0-curl \
    php7.0-intl \
    php7.0-xsl \
    php7.0-mbstring \
    php7.0-zip \
    php7.0-bcmath \
    php7.0-iconv \
    php7.0-fpm


# nginx configuration
COPY default /etc/nginx/sites-available/default

WORKDIR /var/www/html

# install magento script
ADD start.sh /
#ADD magento.sql /
RUN chmod +x /start.sh
#RUN chmod +x /magento.sql
ENTRYPOINT ["bash", "-c"]
CMD ["/start.sh"]

start.sh file:

#!/bin/bash

# Start needed service

service nginx start  && service php7.0-fpm start

if [ ${MAGENTO_INSTALL} == "Yes" ] ; then
echo "Magento 2 already installed"
  service php7.0-fpm restart && service nginx restart && service cron restart  && service ssh restart
else

echo "Magento 2 Installation Process Start"

# ownership
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 777 /var/www/html

# Install magento 2
cd /var/www/html


echo "[+] Installing..."
install_cmd="php bin/magento setup:install \
  --db-host="${MYSQL_HOST}" \
  --db-name="${MYSQL_DATABASE}" \
  --db-user="${MYSQL_USER}" \
  --db-password="${MYSQL_PASSWORD}" \
  --backend-frontname="${BACKEND_FRONTNAME}" \
  --base-url="${BASE_URL}" \
  --language="${DEFAULT_LANGUAGE}" \
  --currency="${DEFAULT_CURRENCY}" \
  --timezone="${DEFAULT_TIMEZONE}" \
  --admin-lastname="${ADMIN_LASTNAME}" \
  --admin-firstname="${ADMIN_FIRSTNAME}" \
  --admin-email="${ADMIN_EMAIL}" \
  --admin-user="${ADMIN_USERNAME}" \
  --admin-password="${ADMIN_PASSWORD}" \
  --use-secure=0 \
  --use-rewrites=1 \
  --use-secure-admin=0 \
  --session-save=files"

eval ${install_cmd}

export MAGENTO_INSTALL="Yes"

echo "magento 2 Installation Completed"


fi

nginx Configuration:

  upstream fastcgi_backend {
   server   unix:/run/php/php7.0-fpm.sock;
}
server {
   listen 80;
   server_name 10.1.2.216;


   set $MAGE_ROOT /var/www/html;
   set $MAGE_MODE developer;

   include /var/www/html/nginx.conf.sample;
}

After create the container, start.sh to install magento2, magento 2 installation fine, after install magento2, container goes to shutdown. then start same container, its started but goes to shutdown.

note: now, I separated mysql machine as new container its works fine.

Suggest me What error in my file or any other way to did this.

1

The problem might be that you are installing Magento in the ENTRYPOINT script, which runs every time. You usually want the entrypoint to be some non-interactive daemon, like the PHP service.

The ENTRYPOINT specifies a command that will always be executed when the container starts. The CMD specifies arguments that will be fed to the ENTRYPOINT.

Here are some potentially helpful resources:

And some other Magento Docker containers to look at:

I have been running Magento's "DevBox" Docker development environment with no issues, so maybe there are some helpful examples in their repo you can look at:

https://github.com/magento/magento2devbox-web

In "DevBox" the Magento command line install is done in the Dockerfile, not the entrypoint script.

The Docker events command can also be helpful for debugging, if you haven't tried that yet.

  • I know that, Its difficult to answer this because, I should not give any error information. I expect some one experienced this issue. – Rajkumar .E Jun 13 '17 at 8:41
  • I have another one doubt, why magento2-devbox using 2 docker machine 1. php+apache 2. mysql? Is there any issue use both as a single machine? because I am using both as a single machine. – Rajkumar .E Jun 13 '17 at 8:44
  • It is common practice to break out separate services, like the database, into their own containers with Docker. This allows more easily scaling or upgrading an individual service. It's part of the "microservices" paradigm. "It is generally recommended that you separate areas of concern by using one service per container.": docs.docker.com/engine/admin/multi-service_container – thaddeusmt Jun 13 '17 at 13:35
  • 1
    I updated my question – Rajkumar .E Jun 13 '17 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.