我是Docker的新手。我正在尝试使用docker使用我已经在本地工作的现有设置来安装Magento2。我的网址是./,我的数据库位于/ var / lib / mysql中。当我做docker-compose up -d我的mysql容器最终停止工作并且容器没有链接到db。我不知道它为什么不工作或链接。
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
答案 0 :(得分:0)
Docker正在使用所有内存来购买更大的Droplet