Combine the official nginx and php-fpm images

GitHub

Docker Hub

Support Tags

TagsNginxPHP
latest1.14.27.3.0
7.31.14.27.3.0
7.21.14.27.2.13

Build Docker images

docker build -t tanghengzhi/nginx-php-fpm .

docker build -f 7.3/Dockerfile -t tanghengzhi/nginx-php-fpm:7.3

docker build -f 7.2/Dockerfile -t tanghengzhi/nginx-php-fpm:7.2

Push Docker images to Docker Cloud

docker push tanghengzhi/nginx-php-fpm

docker push tanghengzhi/nginx-php-fpm:7.3

docker push tanghengzhi/nginx-php-fpm:7.2

Automated Builds

Build configurations
Automated Builds

参考:

https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
https://github.com/nginxinc/docker-nginx/blob/1fe92b86a3c3a6482c54a0858d1fcb22e591279f/stable/stretch/Dockerfile
https://github.com/docker-library/php/blob/b99209cc078ebb7bf4614e870c2d69e0b3bed399/7.2/stretch/fpm/Dockerfile
https://docs.docker.com/config/containers/multi-service_container/
https://docs.docker.com/docker-cloud/builds/automated-build/

387 total views, no views today

WordPress on Docker

首先,创建配置文件 composer-compose.yml。

version: '3.3'

services:

  nginx:
    image: nginx
    restart: always
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./:/var/www/html
    ports:
      - 80:80

  wordpress:
    image: wordpress:php7.2-fpm
    restart: always
    volumes:
      - ./:/var/www/html
    environment:
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: wordpress

  mysql:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: wordpress

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

启动容器:执行如下命令自动下载需要的 Docker 镜像,然后启动容器。

docker-composer up -d

关闭容器:执行如下命令会首先关闭容器,然后移除容器和默认网络,但是不会清空数据库。

docker-composer down

参考:

https://docs.docker.com/compose/wordpress/
https://hub.docker.com/_/wordpress/
https://hub.docker.com/_/mysql/
https://hub.docker.com/_/nginx/

433 total views, no views today

从 Vagrant 到 Docker

最近看了《第一本 Docker 书》,尝试用 docker 来搭一个 lnmp 环境,看看能不能代替 vagrant。


Create Dockerfile

Dockerfile

FROM ubuntu:16.04

RUN echo "mysql-server mysql-server/root_password password root" | debconf-set-selections
RUN echo "mysql-server mysql-server/root_password_again password root" | debconf-set-selections

RUN apt-get update && apt-get install -y \
nginx \
mysql-server \
php7.0-cli \
php7.0-fpm \
php7.0-mysql \
php7.0-curl \
php7.0-gd \
php7.0-mbstring \
php7.0-mcrypt \
php7.0-xml \
php7.0-zip \
curl

EXPOSE 80 443 3306

COPY ./scripts/startup.sh /opt/scripts/startup.sh

CMD ["bash", "/opt/scripts/startup.sh"]

scripts/startup.sh

#!/bin/bash

/etc/init.d/nginx start & /etc/init.d/mysql start & /etc/init.d/php7.0-fpm start

Build

docker build -t lnmp:ubuntu-16.04 .

Run

docker run -it --rm lnmp:ubuntu-16.04

参考:

http://tech.osteel.me/posts/2015/12/18/from-vagrant-to-docker-how-to-use-docker-for-local-web-development.html
http://tech.osteel.me/posts/2017/01/15/how-to-use-docker-for-local-web-development-an-update.html

290 total views, 2 views today