imzyf / mydock

My Laradock

Home Page:https://github.com/imzyf/phpdock

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My Environment Dock

使用 Docker 搭建自己的开发环境。

下载项目

git clone https://github.com/imzyf/my-dock.git

配置项目

本地化环境设置:

cp env-example .env

# OR

cp my-env-example .env

启动并构建:

bash sync.sh up workspace php-worker nginx  mysql php-fpm

docker-compose up -d workspace php-worker nginx redis mysql

docker-compose up --build -d workspace php-worker nginx redis mysql

返回上一级目录:

cd ..
mkdir public
echo "<?php phpinfo(); ?>" > public/index.php

可访问 http://localhost 参看效果。

快捷命令

进入 workspace bash

./sync.sh bash

docker 安装

Get Docker Engine - Community for Ubuntu | docker

$ sudo apt-get update

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88

$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

$ sudo apt-get update

$ sudo apt-get install docker-ce

Install Docker Compose | docker

$ sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

issues

多项目间的通信

例如有两个项目:

  1. api project api.test
  2. web project web.test 需要访问 api.test

这时候会遇到:

Failed to connect to api.test port 80: Connection refused

解决办法:

# 查看 nginx ip
$ docker-compose exec php-fpm ping nginx

docker-compose.ymlphp-fpm 下的 extra_hosts 中补充:

- "api.dev:👆 得到的 nginx ip"

shell

# install es ik
docker-compose exec elasticsearch elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.6/elasticsearch-analysis-ik-7.17.6.zip

References

About

My Laradock

https://github.com/imzyf/phpdock

License:MIT License


Languages

Language:Dockerfile 76.0%Language:Shell 24.0%