尝试使用docker-compose设置db-less kong时出错



我正在尝试设置kong db-less我创建了一个docker文件,如下所示:

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"

和香港。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 up,但日志中有错误

*- [+] Running 1/0

  • 容器无源创建0.0s
  • 连接到kong-dbless
  • kong-dbless | 2022/04/29 01:31:52 [warn] 1#0:用户;指令只有在主进程以超级用户权限运行时才有意义,在/usr/local/kongh/nginx.conf:6
  • kong-dbless | nginx: [warning] the "user"指令只有在主进程以超级用户权限运行时才有意义,在/usr/local/kongh/nginx.conf:6
  • 1#0: init_by_lua错误:/usr/local/share/lua/5.1/kong/init.lua:553:解析声明性配置文件/kong/declarative/kong.yml:
  • kong-dbless |/kong/declarative/kong。没有这样的文件或目录
  • stack trace:
  • [C]:在函数'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:解析声明性配置文件/kong/declarative/kong.yml:
  • [C]:在函数'error'
  • kong-dbless |/usr/local/share/lua/5.1/kong/init.lua:553: in function 'init'
  • *

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


我也试过了,但没有工作:

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"

这对我有用

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"

最新更新