Loading... 我之前项目用的`bitnami/etcd`的镜像 但是最近发现没办法构建项目了,一看etcd出问题了 看了一下docker hub 上面没有tag了 搜索了一下: - Bitnami 是 **VMware** 旗下的镜像维护者,他们从 2024 年底开始逐步 **下架或迁移部分镜像** ,尤其是不再维护的组件。 所以需要换成其它镜像 - `gcr.io/etcd-development/etcd` - `quay.io/coreos/etcd` 我一直用的`FROM quay.io/coreos/etcd:v3.5.15` 换了一下就没问题了 如果之前使用的`bitnami/etcd`的话换了新镜像可能会出现连接不上,因为没帮你监听端口 需要在docker-compose中增加几行开放端口监听 小坑: * **Bitnami 镜像** 会识别 `ETCD_LISTEN_CLIENT_URLS` 这种环境变量。 * **官方镜像** (`quay.io/coreos/etcd`)其实**不会**自动解析环境变量。 它只认命令行参数(`--listen-client-urls` 这种)。 ```yaml etcd: # 自定义容器名称 build: context: ./etcd # 指定构建使用的 Dockerfile 文件 environment: - TZ=${TZ} - ALLOW_NONE_AUTHENTICATION=yes command: - /usr/local/bin/etcd - --name=etcd0 - --data-dir=/etcd-data - --listen-client-urls=http://0.0.0.0:2379 - --advertise-client-urls=http://etcd:2379 - --listen-peer-urls=http://0.0.0.0:2380 - --initial-advertise-peer-urls=http://etcd:2380 - --initial-cluster=etcd0=http://etcd:2380 - --initial-cluster-token=etcd-cluster-1 - --initial-cluster-state=new ports: # 设置端口映射 - "${ETCD_PORT}:2379" networks: - backend restart: always ``` Dockerfile ```bash CMD ["/usr/local/bin/etcd", "--name=etcd0", "--data-dir=/etcd-data", "--listen-client-urls=http://0.0.0.0:2379", "--advertise-client-urls=http://etcd:2379", "--listen-peer-urls=http://0.0.0.0:2380", "--initial-advertise-peer-urls=http://etcd:2380", "--initial-cluster=etcd0=http://etcd:2380", "--initial-cluster-token=etcd-cluster-1", "--initial-cluster-state=new"] ``` 最后修改:2025 年 10 月 16 日 © 允许规范转载 打赏 赞赏作者 微信 赞 1 如果觉得我的文章对你有用,请随意赞赏
此处评论已关闭