Coder Social home page Coder Social logo

just-bean / dockerenv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from inhere/dcenv

0.0 1.0 0.0 20.4 MB

PHP development stack: Nginx, MySQL, MongoDB, PHP-FPM, Swoole, Redis

License: MIT License

Batchfile 0.04% PHP 65.89% Shell 7.86% Dockerfile 26.19% Hack 0.01%

dockerenv's Introduction

Dockerenv

Form kasperisager/php-dockerized


PHP development stack: Nginx, MySQL, MongoDB, PHP-FPM, Gearman, Memcached, Redis, Elasticsearch and RabbitMQ

完整的一整套php开发环境。以及一些扩展的环境

包含容器

运行需求

获取

$ git clone https://github.com/inhere/dockerenv.git  

运行

use Docker For Windows/ Docker for Mac

需要先下载 Docker For Windows 或者 Docker for Mac

需要windows 10 x64版本,并且需要开启 Hyper-V. Mac 则需要 OS X 10.10.3 或者更高版本

直接运行 Docker For Windows / Docker for Mac, 这个版本不需要 docker-machine.

启动docker,然后运行:

$ cp docker-compose.56.yml docker-compose.yml # 拷贝需要的配置
$ docker-compose up
// $ docker-compose up -d // 后台运行
$ docker ps // 查看正在运行的容器列表

Questions - 问题

  • compose v3 版本不在支持 extends

自定义构建参数

大部分自定义容器都添加了自定义构建参数,需要传入. 如:

php7:
  build:
    context: .
    dockerfile: ./services/php/Dockerfile
    args:
      fpmport: "9001"
      timezone: Asia/Shanghai 

配置文件不是默认的名称

若要使用配置文件不是默认名称docker-compose.yml的,除了拷贝重命名为默认名称 docker-compose.yml 外, 也可使用-f {filename}参数.

$ docker-compose -f docker-compose.70.yml up -d
  • -f {filename} 指定 compose 配置文件
  • -p {project name} 指定项目名称,默认是文件夹的名称
  • -d 后台运行

nginx 站点配置

若使用的是nginx和php分开的服务容器,注意站点配置中

    fastcgi_pass  unix:/var/run/php5-fpm.sock;

要换成访问php容器的9000端口

    fastcgi_pass  webapp:9000;

一些有用的

  • bash alias

in the ~/.bashrc

alias dc=docker
#alias dcm=docker-machine
alias dcc=docker-compose
# 快速进入一个常用容器
alias gophp='docker exec -ti dev-php bash'
# 杀死所有正在运行的容器.
alias dockerkill='docker kill $(docker ps -a -q)'
# 删除所有已经停止的容器.
alias dockercleanc='docker rm $(docker ps -a -q)'
# 删除所有未打标签的镜像.
alias dockercleani='docker rmi $(docker images -q -f dangling=true)'
  • 添加 .dockerignore 文件

推荐添加 .dockerignore 文件,定义忽略文件/夹

因为 docker build 时会发送 context 目录的所有文件到 Docker daemon, 若context目录下有很多文件会造成花费时间很长,甚至程序卡死。

e.g

node_modules/
.git/
www/
# data/
logs/
# tools/
# services/
Dockerfile
*.Dockerfile
*.tar.gz
*.tgz
*.zip
*.md

注意:若文件夹中有文件被 Dockerfile 使用,则不能将此文件夹加入忽略,否则 docker 构建时会报找不到文件

一些容器默认信息

You'll need to configure your application to use any services you enabled:

Service Hostname Port number
webapp(php-fpm) webapp 9000
webserver(nginx) webserver 80 (http) / 443 (ssl)
MySQL mysql 3306 (default)
Gearman gearman 4730 (default)
Memcached memcached 11211 (default)
Redis redis 6379 (default)
Elasticsearch elasticsearch 9200 (HTTP default) / 9300 (ES transport default)

License

Licensed under the terms of the MIT license.

dockerenv's People

Contributors

daper avatar dol avatar inhere avatar kasperisager avatar mckomo avatar pgrau avatar sseidenthal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.