错误试图使用Docker-Compose设置无DB的Kong

发布于 01-25 04:47 字数 3112 浏览 1 评论 0原文

我正在尝试建立kong db-db- 我已经创建了一个如下:

FROM kong
USER 0
RUN mkdir -p /kong/declarative/
COPY kong.yml /usr/local/etc/kong/kong.yml
USER kong

Docker-Compose文件,而

version: "3.8"

networks:
 kong-net:

services:
  kong:
    container_name: kong-dbless
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    networks:
      - kong-net
    environment:
      - KONG_DATABASE=off
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - KONG_PROXY_ACCESS_LOG=/dev/stdout
      - KONG_ADMIN_ACCESS_LOG=/dev/stdout
      - KONG_PROXY_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_ERROR_LOG=/dev/stderr
      - KONG_DECLARATIVE_CONFIG=/usr/local/etc/kong/kong.yml
    ports:
      - "8001:8001"
      - "8444:8444"
      - "80:8000"
      - "443:8443"

Kong.yaml如下

 _format_version: "1.1"
 _transform: true

 services:
 - host: mockbin.org
   name: example_service
   port: 80
   protocol: http
   routes:
 - name: example_route
     paths:
     - /mock
     strip_path: true

我运行docker-compose ,但我在日志中错误

* - [+]运行1/0运行1/0

  • 集装箱Kong-Dbles创建了0.0 s,
  • 附加到Kong-Dbless
  • Kong-Dbless | 2022/04/29 01:31:52 [WARN] 1#0:“用户”指令只有在主过程以super-user特权运行时,在/usr/local/kong/nginx.6中忽略了“用户”指令才有意义
  • Kong-Dbless | nginx:[警告]“用户”指令仅在主过程以超级用户特权运行时才有意义,在/usr/local/kong/nginx.conf:6
  • kong-dbless | 2022/04/29 01:31:52 [错误] 1#0:init_by_lua error:/usr/local/share/share/lua/5.1/kong/init.lua:553:错误解析声明声明config file/kong/kong/kong/kong/kong/kong/kong/kong/kong/kong .yml:
  • Kong-Dbless | /kong/declarative/kong.yml:没有这样的文件或目录
  • kong-dbless |堆栈追溯:
  • Kong-Dbless | [C]:在功能'错误'
  • Kong-Dbless中| /USR/local/share/lua/5.1/kong/init.lua:553:在功能'init'kong
  • -dbless | nginx:[error] init_by_lua错误:/USR/local/share/lua/5.1/kong/init.lua:553:错误解析声明config config file/kong/declarative/kong.yml:
  • kong-dbless:kong-dbless | [C]:在功能'错误'
  • Kong-Dbless中| /USR/local/share/lua/5.1/kong/init.lua:553:在功能'init'kong
  • -dbless | init_by_lua:3:在主块*中

有人知道问题是什么,我该如何解决?


我也尝试过,但没有起作用:

dockerfile

FROM kong
COPY kong.yml /
RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf

docker-compose

version: "3.8"

networks:
 kong-net:

services:
  kong:
    container_name: kong-dbless
    build:
      context: .
      dockerfile: Dockerfile
#    restart: unless-stopped
    networks:
      - kong-net
    healthcheck:
      test: [ “CMD”, “curl”, “-f”, “http://kong:8000” ]
      interval: 5s
      timeout: 2s
      retries: 15
    environment:
      - KONG_DATABASE=off
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - KONG_PROXY_ACCESS_LOG=/dev/stdout
      - KONG_ADMIN_ACCESS_LOG=/dev/stdout
      - KONG_PROXY_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_ERROR_LOG=/dev/stderr
      - KONG_DECLARATIVE_CONFIG=kong.yml
    ports:
      - "8001:8001"
      - "8444:8444"
      - "80:8000"
      - "443:8443"

I am trying to set up kong db-less
I have created a docker file as below:

FROM kong
USER 0
RUN mkdir -p /kong/declarative/
COPY kong.yml /usr/local/etc/kong/kong.yml
USER kong

and a docker-compose file

version: "3.8"

networks:
 kong-net:

services:
  kong:
    container_name: kong-dbless
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    networks:
      - kong-net
    environment:
      - KONG_DATABASE=off
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - KONG_PROXY_ACCESS_LOG=/dev/stdout
      - KONG_ADMIN_ACCESS_LOG=/dev/stdout
      - KONG_PROXY_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_ERROR_LOG=/dev/stderr
      - KONG_DECLARATIVE_CONFIG=/usr/local/etc/kong/kong.yml
    ports:
      - "8001:8001"
      - "8444:8444"
      - "80:8000"
      - "443:8443"

and kong.yaml is as below

 _format_version: "1.1"
 _transform: true

 services:
 - host: mockbin.org
   name: example_service
   port: 80
   protocol: http
   routes:
 - name: example_route
     paths:
     - /mock
     strip_path: true

I run docker-compose up but I errors in the log

*- [+] Running 1/0

  • Container kong-dbless Created 0.0s
  • Attaching to kong-dbless
  • kong-dbless | 2022/04/29 01:31:52 [warn] 1#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:6
  • kong-dbless | nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /usr/local/kong/nginx.conf:6
  • kong-dbless | 2022/04/29 01:31:52 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:553: error parsing declarative config file /kong/declarative/kong.yml:
  • kong-dbless | /kong/declarative/kong.yml: No such file or directory
  • kong-dbless | stack traceback:
  • kong-dbless | [C]: in function 'error'
  • kong-dbless | /usr/local/share/lua/5.1/kong/init.lua:553: in function 'init'
  • kong-dbless | nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:553: error parsing declarative config file /kong/declarative/kong.yml:
  • kong-dbless | [C]: in function 'error'
  • kong-dbless | /usr/local/share/lua/5.1/kong/init.lua:553: in function 'init'
  • kong-dbless | init_by_lua:3: in main chunk*

Does anybody know what the problem is and how should I fix it?


Also I tried this but did not work:

Dockerfile

FROM kong
COPY kong.yml /
RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf

docker-compose

version: "3.8"

networks:
 kong-net:

services:
  kong:
    container_name: kong-dbless
    build:
      context: .
      dockerfile: Dockerfile
#    restart: unless-stopped
    networks:
      - kong-net
    healthcheck:
      test: [ “CMD”, “curl”, “-f”, “http://kong:8000” ]
      interval: 5s
      timeout: 2s
      retries: 15
    environment:
      - KONG_DATABASE=off
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - KONG_PROXY_ACCESS_LOG=/dev/stdout
      - KONG_ADMIN_ACCESS_LOG=/dev/stdout
      - KONG_PROXY_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_ERROR_LOG=/dev/stderr
      - KONG_DECLARATIVE_CONFIG=kong.yml
    ports:
      - "8001:8001"
      - "8444:8444"
      - "80:8000"
      - "443:8443"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

左耳近心2025-02-01 04:47:37

这对我

FROM kong
USER 0
RUN mkdir -p /kong/declarative/
COPY declarative/kong.yml /kong/declarative/
RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf
USER kong

有用

version: "3.8"

networks:
 kong-net:

services:
  kong:
    container_name: kong
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    networks:
      - kong-net
    healthcheck:
      test: [ “CMD”, “curl”, “-f”, “http://kong:8000” ]
      interval: 5s
      timeout: 2s
      retries: 15
    environment:
      - KONG_DATABASE=off
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - KONG_PROXY_ACCESS_LOG=/dev/stdout
      - KONG_ADMIN_ACCESS_LOG=/dev/stdout
      - KONG_PROXY_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_ERROR_LOG=/dev/stderr
      - KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml
    ports:
      - "8444:8444"
      - "80:8000"
      - "443:8443"

This worked for me

FROM kong
USER 0
RUN mkdir -p /kong/declarative/
COPY declarative/kong.yml /kong/declarative/
RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf
USER kong

and

version: "3.8"

networks:
 kong-net:

services:
  kong:
    container_name: kong
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    networks:
      - kong-net
    healthcheck:
      test: [ “CMD”, “curl”, “-f”, “http://kong:8000” ]
      interval: 5s
      timeout: 2s
      retries: 15
    environment:
      - KONG_DATABASE=off
      - KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl
      - KONG_PROXY_ACCESS_LOG=/dev/stdout
      - KONG_ADMIN_ACCESS_LOG=/dev/stdout
      - KONG_PROXY_ERROR_LOG=/dev/stderr
      - KONG_ADMIN_ERROR_LOG=/dev/stderr
      - KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml
    ports:
      - "8444:8444"
      - "80:8000"
      - "443:8443"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文