环境
- EMQX 版本:4.4.19
- 操作系统版本:docker容器
重现此问题的步骤
- 首次docker启动将/opt/emqx/data/loaded_plugins、/opt/emqx/etc/acl/conf、/opt/emqx/etc/emqx.conf文件拷贝到宿主机
- 修改上边三个文件内容 如acl策略等其他配置,在loaded_plugins文件中添加mysql鉴权插件
- 制作dockerfile 同时将三个修改后的文件复制到docker容器中
4.镜像制作完成,启动容器,发现emqx_auth_mysql插件没有自动启用
dockerfile文件内容:
FROM debian:11-slim
RUN set -eu;
apt-get update;
apt-get install -y --no-install-recommends curl unzip ca-certificates;
rm -rf /var/lib/apt/lists/*
RUN set -eu;
groupadd -r -g 1000 emqx;
useradd -r -m -u 1000 -g emqx emqx
ENV EMQX_VERSION=4.4.19
ENV OTP=otp24.3.4.2-1
RUN set -eu;
arch=$(dpkg --print-architecture);
if [ ${arch} = “amd64” ]; then sha256=“bf4192c64c9006733b30f96fe99506a0a3af115c7073995a044cc0e60230675e”; fi;
if [ ${arch} = “arm64” ]; then sha256=“7cd27d5112380fd4d81029b10ba862a050b0bba8af1eb90aac669189fc3053c0”; fi;
ID=“$(sed -n ‘/^ID=/p’ /etc/os-release | sed -r ‘s/ID=(.)/\1/g’ | sed ‘s/"//g’)“;
VERSION_ID=”$(sed -n ‘/^VERSION_ID=/p’ /etc/os-release | sed -r 's/VERSION_ID=(.)/\1/g’ | sed ‘s/"//g’)”;
pkg=“emqx-${EMQX_VERSION}-${OTP}-${ID}${VERSION_ID}-${arch}.zip”;
curl -f -O -L https://www.emqx.com/en/downloads/broker/${EMQX_VERSION}/${pkg};
echo “$(sha256sum $pkg)”;
echo "$sha256 $pkg" | sha256sum -c;
unzip -q -d /opt $pkg;
chgrp -Rf emqx /opt/emqx;
chmod -Rf g+w /opt/emqx;
chown -Rf emqx /opt/emqx;
ln -s /opt/emqx/bin/ /usr/local/bin/;
rm -rf $pkg
WORKDIR /opt/emqx
USER emqx
VOLUME [“/opt/emqx/log”, “/opt/emqx/data”]
emqx will occupy these port:
- 1883 port for MQTT
- 8081 for mgmt API
- 8083 for WebSocket/HTTP
- 8084 for WSS/HTTPS
- 8883 port for MQTT(SSL)
- 11883 port for internal MQTT/TCP
- 18083 for dashboard
- 4369 epmd (Erlang-distrbution port mapper daemon) listener (deprecated)
- 4370 default Erlang distrbution port
- 5369 for gen_rpc port mapping
- 6369 6370 for distributed node
EXPOSE 1883 8081 8083 8084 8883 11883 18083 4369 4370 5369 6369 6370
COPY docker-entrypoint.sh /usr/bin/
COPY acl.conf /opt/emqx/etc
COPY emqx.conf /opt/emqx/etc
COPY loaded_plugins /var/lib/emqx/
ENTRYPOINT [“/usr/bin/docker-entrypoint.sh”]
CMD [“emqx”, “foreground”]
预期行为
docker启动指令:
emqx4]# docker run -itd --network host -p 1883:1883 -p 8081:8081 -p 8183:8083 -p 8884:8883 -p 8084:8084 -p 18083:18083 -v /etc/localtime:/etc/localtime -v /data/docker/emqx/data/mnesia:/opt/emqx/data/mnesia -e EMQX_AUTH__MYSQL__DATABASE=pksite -e EMQX_AUTH__MYSQL__SERVER=127.0.0.1:3306 -e EMQX_AUTH__MYSQL__USERNAME=root -e EMQX_AUTH__MYSQL__PASSWORD=root --name emqx emqx/emqx:test