简体   繁体   English

使用 laradock 使用 laravel 和 docker 集群创建集群的问题

[英]Problem to make a cluster with laravel and docker swarm using laradock

I recently started with docker and I have been following this steps to make a cluster with laradock https://github.com/jarnovanleeuwen/laravel-dock我最近从 docker 开始,我一直在按照这些步骤使用 laradock https 制作集群://github.com/jarnovanleeuwen/laravel-dock

first I create with docker-machine 2 nodes, one manager and the other a worker then with this comand I set the manager node as the leader首先,我使用 docker-machine 2 个节点创建一个管理器,另一个是工作人员,然后使用此命令将管理器节点设置为领导者

docker swarm init --advertise-addr 192.168.99.100

I add the other node as a worker with我将另一个节点添加为工作人员

docker swarm join

After I access the manager node with docker-machine ssh manager and create a service在我使用 docker-machine ssh manager 访问管理器节点并创建服务后

docker service create --name registry --publish published=5000,target=5000 registry:2

I leave the virtual machine with exit and cd into the folder laravel-dock, then I up the containers to create the images with我将退出的虚拟机和 cd 留在文件夹 laravel-dock 中,然后我启动容器以创建图像

./dock up

then I set it down然后我把它放下

./dock down

I build the image with我用

./dock build

Then i push it into the service I created with然后我将它推送到我创建的服务中

./dock push

The push refers to repository [192.168.99.100:5000/registry]
Get https://192.168.99.100:5000/v2/: http: server gave HTTP response to HTTPS client

With this I try to deploy the stack with有了这个我尝试部署堆栈

./dock deploy

Are you sure you want to deploy [192.168.99.100:5000/registry:web] to [docker@192.168.99.100]? (y/N) y

Uploading deployment configuration...The authenticity of host '192.168.99.100 (192.168.99.100)' can't be established.
ECDSA key fingerprint is SHA256:r1F+7kuet+grlysNruBECAmYpRVVlvORYhAR4ipNFco.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.99.100' (ECDSA) to the list of known hosts.
docker@192.168.99.100's password: 
docker@192.168.99.100's password: 
OK
docker@192.168.99.100's password: 
./dock-swarm: line 4: .env: No such file or directory

it request the password for the machine that is "tcuser" and come with this error ".env: No such file or directory", so I manually copy the.env to this folder created in the manager node with它请求机器“tcuser”的密码并出现此错误“.env:没有这样的文件或目录”,所以我手动将.env复制到在管理器节点中创建的这个文件夹中

docker-machine scp -r .env manager:/home/docker/laraveldock

I try to deploy again and have this error我尝试再次部署并出现此错误

sudo ./dock deploy


Are you sure you want to deploy [192.168.99.100:5000/registry:web] to [docker@192.168.99.100]? (y/N) y

Uploading deployment configuration...docker@192.168.99.100's password: 
docker@192.168.99.100's password: 
OK
docker@192.168.99.100's password: 
Top-level object must be a mapping

And at this point I have stuck with this error, am I doing something wrong in this steps?在这一点上,我一直遇到这个错误,我在这个步骤中做错了吗? also here is the configurations这里也是配置

.env .env

APP_ID=laraveldock
DEPLOY_SERVER=docker@192.168.99.100
DOCKER_REPOSITORY=192.168.99.100:5000/registry:web

REGISTRY=localhost:5000
REGISTRY_USER=docker
REGISTRY_PASSWORD=tcuser

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:25q1JJ78zFzeGYOBIyIndCmuSJBOCaezyW2utE7hE3Y=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_DATABASE=laraveldock
DB_USERNAME=root
DB_PASSWORD=secret

REDIS_PASSWORD=rediz

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
DB_DATABASE=laraveldock
DB_USERNAME=root
DB_PASSWORD=secret

REDIS_PASSWORD=rediz

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

docker-compose.yml docker-compose.yml

version: '3.7'

# Volumes
volumes:
  mysql:
    driver: local
  redis:
    driver: local

services:

  # Apache + PHP
  app:

    environment:
      - CONTAINER_ROLE=app
      - DB_HOST=db
      - DB_PORT=3306
      - REDIS_HOST=redis
      - REDIS_PORT=6379
    env_file: ../.env
    ports:
      - "80:80"

  # Scheduler
  scheduler:
    user: webdev
    environment:
      - CONTAINER_ROLE=scheduler
      - DB_HOST=db
      - DB_PORT=3306
      - REDIS_HOST=redis
      - REDIS_PORT=6379
    env_file: ../.env

  # Queue worker
  queue:
    user: webdev
    environment:
      - CONTAINER_ROLE=queue
      - DB_HOST=db
      - DB_PORT=3306
      - REDIS_HOST=redis
      - REDIS_PORT=6379
    env_file: ../.env

  # MySQL
  db:
    image: mysql:5.7
    command: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"]
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
      - MYSQL_DATABASE=${DB_DATABASE}
    ports:
      - "3306:3306"
    volumes:
      - mysql:/var/lib/mysql/

  # Redis
  redis:
    image: redis:5.0
    command: ["redis-server", "--appendonly", "yes", "--requirepass", "${REDIS_PASSWORD}"]

I spent an hour on this bug.我在这个错误上花了一个小时。 In my case problem was caused by missing docker-compose on remote server.在我的情况下,问题是由于远程服务器上缺少 docker-compose 引起的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM