tzssangglass opened a new issue #3146:
URL: https://github.com/apache/apisix/issues/3146
### Issue description
I used the following Dockerfile to build the image
```
FROM centos:7
ARG APISIX_VERSION=2.1
LABEL apisix_version="${APISIX_VERSION}"
RUN yum -y install yum-utils\
&& yum-config-manager --add-repo
https://openresty.org/package/centos/openresty.repo \
&& yum install -y openresty \
&& yum install -y
https://github.com/apache/apisix/releases/download/$APISIX_VERSION/apisix-$APISIX_VERSION-0.el7.noarch.rpm
\
&& yum clean all \
&& sed -i 's/PASS_MAX_DAYS\t99999/PASS_MAX_DAYS\t60/g' /etc/login.defs
WORKDIR /usr/local/apisix
COPY apisix/plugins/ /usr/local/apisix/plugins/
COPY conf/config.yaml /usr/local/apisix/conf/config.yaml
EXPOSE 9080 9180
CMD ["sh", "-c", "/usr/bin/apisix init && /usr/bin/apisix init_etcd &&
/usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'"]
```
the config.yaml is
```
apisix:
admin_key:
- name: "admin"
key: ${{ADMIN_KEY}}
role: admin
allow_admin:
port_admin: 9180
enable_server_tokens: false
ssl:
enable: false
enable_http2: false
etcd:
host:
- ${{ETCD_ENDPOINT_1}}
- ${{ETCD_ENDPOINT_2}}
- ${{ETCD_ENDPOINT_3}}
prefix: "/apisix"
timeout: 30
resync_delay: 5
user: ${{ETCD_USER}}
password: ${{ETCD_PWD}}
tls:
verify: false
plugins:
- proxy-rewrite
- log-rotate
- prometheus
plugin_attr:
log-rotate:
interval: 3600
max_kept: 24
prometheus:
export_uri: /apisix/prometheus/metrics
```
build docker image
` docker build -t apisix/test:v0.0.2 . `
start docker
`docker run -d --name apisix-test -p 9080:9080 -p 9180:9180 -e
ADMIN_KEY=edd1c9f034335f136f87ad84b625c8f2 -e
ETCD_ENDPOINT_1="http://172.19.177.122:12379" -e
ETCD_ENDPOINT_2="http://172.19.177.122:22379" -e
ETCD_ENDPOINT_3="http://172.19.177.122:32379" -e ETCD_USER=root -e
ETCD_PWD=abc123 apisix/test:v0.0.2`
docker can start normally, but it keeps reporting errors inside
```
2020/12/28 11:37:27 [error] 41#41: *696793 [lua] config_etcd.lua:529: failed
to fetch data from etcd: /usr/local/apisix/apisix/core/config_etcd.lua:499:
failed to create etcd instance for key [/apisix/consumers]: invalid http host:
${{ETCD_ENDPOINT_1}}, err: not matched
stack traceback:
[C]: in function 'error'
/usr/local/apisix/apisix/core/config_etcd.lua:499: in function
</usr/local/apisix/apisix/core/config_etcd.lua:495>
[C]: in function 'xpcall'
/usr/local/apisix/apisix/core/config_etcd.lua:495: in function
</usr/local/apisix/apisix/core/config_etcd.lua:486>, etcd key:
/apisix/consumers, context: ngx.timer
```
This looks like the timer process can't resolve environment variables when
creating a new etcd connection, or is there something wrong with my
configuration?
I executed echo $ETCD_ENDPOINT_1 inside docker and it was fine
```
[root@5eb4bb3f46d4 apisix]# echo $ETCD_ENDPOINT_1
http://172.19.177.122:12379
```
### Environment
* apisix version (cmd: `apisix version`):2.1
* OS: (cmd: `uname -a`):centos7
* OpenResty / Nginx version: (cmd: `nginx -V` or `openresty -V`):1.19.3.1
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]