doutou7740 2017-05-18 18:31
浏览 84

Docker使用本地数据库进行卷

I am new to Docker. I am trying to use docker to install Magento2 using an existing setup I already have working locally. My web is in ./ and my database is located in /var/lib/mysql. When I do docker-compose up -d my mysql container eventually stops working and the containers are not linking to the db. I have no idea why it is not working or linking.

docker-compose.yml

version: '2'

services:
  web:
    build: .
    ports:
      - "80:80"
    volumes:
     - ./:/var/www/html
    links:
      - db
    env_file:
      - env
    depends_on:
      - db
  db:
    image: mysql:5.7.18
    volumes:
      - /var/lib/mysql:/var/lib/mysql
    env_file:
      - env

Dockerfile:

FROM alexcheng/apache2-php7

MAINTAINER Fu Cheng <alexcheng1982@gmail.com>

RUN a2enmod rewrite

ENV MAGENTO_VERSION 2.1.6

RUN curl -sS https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
RUN requirements="libpng12-dev libmcrypt-dev libmcrypt4 libcurl3-dev libfreetype6 libjpeg-turbo8 libjpeg-turbo8-dev libpng12-dev libfreetype6-dev libicu-dev libxslt1-dev" \
    && apt-get update && apt-get install -y $requirements && rm -rf /var/lib/apt/lists/* \
    && docker-php-ext-install pdo_mysql \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install gd \
    && docker-php-ext-install mcrypt \
    && docker-php-ext-install mbstring \
    && docker-php-ext-install zip \
    && docker-php-ext-install intl \
    && docker-php-ext-install xsl \
    && docker-php-ext-install soap \
    && requirementsToRemove="libpng12-dev libmcrypt-dev libcurl3-dev libpng12-dev libfreetype6-dev libjpeg-turbo8-dev" \
    && apt-get purge --auto-remove -y $requirementsToRemove

COPY ./auth.json /var/www/.composer/
COPY ./ /var/www/html/
RUN chsh -s /bin/bash www-data
RUN chown -R www-data:www-data /var/www
RUN su www-data -c "cd /var/www/html \
    && find . -type d -exec chmod 770 {} \; \
    && find . -type f -exec chmod 660 {} \; \
    && chmod u+x bin/magento"

COPY ./bin/install-magento /usr/local/bin/install-magento
RUN chmod +x /usr/local/bin/install-magento

RUN echo "memory_limit=1024M" > /usr/local/etc/php/conf.d/memory-limit.ini

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

WORKDIR /var/www/html

VOLUME /var/www/html/var
VOLUME /var/www/html/pub

# Add cron job
ADD crontab /etc/cron.d/magento2-cron
RUN chmod 0644 /etc/cron.d/magento2-cron
RUN crontab -u www-data /etc/cron.d/magento2-cron

env:

MYSQL_HOST=db
MYSQL_ROOT_PASSWORD=mypass
MYSQL_USER=myuser
MYSQL_PASSWORD=mypass
MYSQL_DATABASE=mydbname

MAGENTO_LANGUAGE=en_US
MAGENTO_TIMEZONE=America/New_York
MAGENTO_DEFAULT_CURRENCY=USD
MAGENTO_URL=http://<ip of vm>

MAGENTO_ADMIN_FIRSTNAME=admin
MAGENTO_ADMIN_LASTNAME=store
MAGENTO_ADMIN_EMAIL=my@email.com
MAGENTO_ADMIN_USERNAME=admin
MAGENTO_ADMIN_PASSWORD=mypass

docker log db

  2017-05-18T19:14:40.184335Z 0 [Note] mysqld (mysqld 5.7.18) starting as process 1 ...
2017-05-18T19:14:40.200332Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-05-18T19:14:40.200675Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-05-18T19:14:40.200776Z 0 [Note] InnoDB: Uses event mutexes
2017-05-18T19:14:40.200846Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-05-18T19:14:40.200873Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-05-18T19:14:40.200917Z 0 [Note] InnoDB: Using Linux native AIO
2017-05-18T19:14:40.206612Z 0 [Note] InnoDB: Number of pools: 1
2017-05-18T19:14:40.208420Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-05-18T19:14:40.217005Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-05-18T19:14:40.223891Z 0 [ERROR] InnoDB: mmap(137428992 bytes) failed; errno 12
2017-05-18T19:14:40.224185Z 0 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2017-05-18T19:14:40.224254Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-05-18T19:14:40.224324Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-05-18T19:14:40.224352Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-05-18T19:14:40.224398Z 0 [ERROR] Failed to initialize plugins.
2017-05-18T19:14:40.224420Z 0 [ERROR] Aborting

2017-05-18T19:14:40.224455Z 0 [Note] Binlog end
2017-05-18T19:14:40.225243Z 0 [Note] Shutting down plugin 'MyISAM'
2017-05-18T19:14:40.225843Z 0 [Note] Shutting down plugin 'CSV'
2017-05-18T19:14:40.226701Z 0 [Note] mysqld: Shutdown complete
  • 写回答

1条回答 默认 最新

  • dongqiao8417 2017-05-18 20:06
    关注

    Docker was using all the memory had to purchase a bigger droplet

    评论

报告相同问题?

悬赏问题

  • ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?