WordPress
基本資訊
WordPress 是開源的 Blog 和內容管理系統框架,它基於 PhP 和 MySQL。
該倉庫位於 https://hub.docker.com/_/wordpress/,提供了 WordPress 4.x 版本的映像檔。
使用方法
啟動容器需要 MySQL 的支援, 預設連接埠為 80
。
$ docker run --name some-wordpress --link some-mysql:mysql -d wordpress
啟動 WordPress 容器時可以指定的一些環境參數包括:
-e WORDPRESS_DB_USER=...
省略為 「root」-e WORDPRESS_DB_PASSWORD=...
省略為連線 mysql 容器的環境變數MYSQL_ROOT_PASSWORD
的值-e WORDPRESS_DB_NAME=...
省略為 「wordpress」-e WORDPRESS_AUTH_KEY=...
,-e WORDPRESS_SECURE_AUTH_KEY=...
,-e WORDPRESS_LOGGED_IN_KEY=...
,-e WORDPRESS_NONCE_KEY=...
,-e WORDPRESS_AUTH_SALT=...
,-e WORDPRESS_SECURE_AUTH_SALT=...
,-e WORDPRESS_LOGGED_IN_SALT=...
,-e WORDPRESS_NONCE_SALT=...
省略為隨機 sha1 串
Dockerfile
4.0 版本
FROM debian:wheezy
RUN apt-get update && apt-get install -y \
apache2 \
curl \
libapache2-mod-php5 \
php5-curl \
php5-gd \
php5-mysql \
rsync \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN a2enmod rewrite
# copy a few things from apache's init script that it requires to be setup
ENV APACHE_CONFDIR /etc/apache2
ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
# and then a few more from $APACHE_CONFDIR/envvars itself
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_PID_FILE $APACHE_RUN_DIR/apache2.pid
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_LOG_DIR /var/log/apache2
ENV LANG C
RUN mkdir -p $APACHE_RUN_DIR $APACHE_LOCK_DIR $APACHE_LOG_DIR
# make CustomLog (access log) go to stdout instead of files
# and ErrorLog to stderr
RUN find "$APACHE_CONFDIR" -type f -exec sed -ri ' \
s!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g; \
s!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g; \
' '{}' ';'
RUN rm -rf /var/www/html && mkdir /var/www/html
VOLUME /var/www/html
WORKDIR /var/www/html
ENV WORDPRESS_VERSION 4.0.0
ENV WORDPRESS_UPSTREAM_VERSION 4.0
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
RUN curl -SL http://wordpress.org/wordpress-${WORDPRESS_UPSTREAM_VERSION}.tar.gz | tar -xzC /usr/src/
COPY docker-apache.conf /etc/apache2/sites-available/wordpress
RUN a2dissite 000-default && a2ensite wordpress
COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 80
CMD ["apache2", "-DFOREGROUND"]
4.5 版本
FROM php:5.6-apache
RUN a2enmod rewrite expires
# install the PHP extensions we need
RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev && rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd mysqli opcache
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=60'; \
echo 'opcache.fast_shutdown=1'; \
echo 'opcache.enable_cli=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
VOLUME /var/www/html
ENV WORDPRESS_VERSION 4.5.3
ENV WORDPRESS_SHA1 835b68748dae5a9d31c059313cd0150f03a49269
# upstream tarballs include ./wordpress/ so this gives us /usr/src/wordpress
RUN curl -o wordpress.tar.gz -SL https://wordpress.org/wordpress-${WORDPRESS_VERSION}.tar.gz \
&& echo "$WORDPRESS_SHA1 *wordpress.tar.gz" | sha1sum -c - \
&& tar -xzf wordpress.tar.gz -C /usr/src/ \
&& rm wordpress.tar.gz \
&& chown -R www-data:www-data /usr/src/wordpress
COPY docker-entrypoint.sh /entrypoint.sh
# grr, ENTRYPOINT resets CMD now
ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]