Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apple Mac M1 docker环境下nacos无法启动 #6340

Closed
muyuto opened this issue Jul 13, 2021 · 25 comments
Closed

Apple Mac M1 docker环境下nacos无法启动 #6340

muyuto opened this issue Jul 13, 2021 · 25 comments

Comments

@muyuto
Copy link

muyuto commented Jul 13, 2021

感谢 nacos 1.4.0 多平台兼容性疑问 #4336中 plusmancn 的解决方案,通过指定jdk版本后可以运行nacos 2.0.2。但是基于环境的安装配置的复杂程度以及对本地开发环境的配置复杂,不利于快速开展开发,所以还是想继续折腾docker方式的。
官方文档提供的方法启动nacos,standalone模式,配合mysql-server 8依然无法启动,错误日志如下:
14:40:05.050 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
com.alibaba.nacos.api.exception.runtime.NacosRuntimeException: ErrCode:500, ErrMsg:Function not implemented
at com.alibaba.nacos.core.listener.StartingApplicationListener.loadPreProperties(StartingApplicationListener.java:160)
at com.alibaba.nacos.core.listener.StartingApplicationListener.environmentPrepared(StartingApplicationListener.java:99)
at com.alibaba.nacos.core.code.SpringApplicationRunListener.environmentPrepared(SpringApplicationRunListener.java:65)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:342)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
at com.alibaba.nacos.Nacos.main(Nacos.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467)
Caused by: com.alibaba.nacos.api.exception.NacosException: java.io.IOException: Function not implemented
at com.alibaba.nacos.sys.file.WatchFileCenter$WatchDirJob.(WatchFileCenter.java:189)
at com.alibaba.nacos.sys.file.WatchFileCenter.registerWatcher(WatchFileCenter.java:97)
at com.alibaba.nacos.core.listener.StartingApplicationListener.registerWatcher(StartingApplicationListener.java:166)
at com.alibaba.nacos.core.listener.StartingApplicationListener.loadPreProperties(StartingApplicationListener.java:158)
... 16 common frames omitted
Caused by: java.io.IOException: Function not implemented
at sun.nio.fs.LinuxWatchService.(LinuxWatchService.java:64)
at sun.nio.fs.LinuxFileSystem.newWatchService(LinuxFileSystem.java:47)
at com.alibaba.nacos.sys.file.WatchFileCenter$WatchDirJob.(WatchFileCenter.java:184)
... 19 common frames omitted
14:40:05.106 [Thread-4] WARN com.alibaba.nacos.common.executor.ThreadPoolManager - [ThreadPoolManager] Start destroying ThreadPool
14:40:05.109 [Thread-4] WARN com.alibaba.nacos.common.executor.ThreadPoolManager - [ThreadPoolManager] Destruction of the end

求助,谢谢

@muyuto
Copy link
Author

muyuto commented Jul 13, 2021

补充信息:
有错误日志关键信息如下

A fatal error has been detected by the Java Runtime Environment:

SIGILL (0x4) at pc=0x000000400d1b0485, pid=1, tid=0x0000004089932700

JRE version: OpenJDK Runtime Environment (8.0_292-b10) (build 1.8.0_292-b10)

Java VM: OpenJDK 64-Bit Server VM (25.292-b10 mixed mode linux-amd64 compressed oops)

Problematic frame:

J 1507 C1 com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipChar(ILcom/sun/org/apache/xerces/internal/impl/XMLScanner$NameType;)Z (285 bytes) @ 0x000000400d1b0485 [0x000000400d1b0460+0x25]

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

An error report file with more information is saved as:

/home/nacos/hs_err_pid1.log

@KomachiSion
Copy link
Collaborator

Caused by: java.io.IOException: Function not implemented at sun.nio.fs.LinuxWatchService.(LinuxWatchService.java:64)

你的系统没有实现filewatch,换个os版本试试

@muyuto
Copy link
Author

muyuto commented Jul 14, 2021

Caused by: java.io.IOException: Function not implemented at sun.nio.fs.LinuxWatchService.(LinuxWatchService.java:64)

你的系统没有实现filewatch,换个os版本试试

这个是拉取的官方镜像,compose如下
nacos:
image: nacos/nacos-server:${NACOS_VERSION}
platform: linux/x86_64
container_name: nacos
env_file:
- ./nacos-standlone-mysql.env
volumes:
# - nacos_data:/home/nacos/logs
- ./custom.properties:/home/nacos/init.d/custom.properties
ports:
- "8848:8848"
- "9848:9848"
- "9849:9849"
- "9555:9555"
external_links:
- mysql8:mysql8
- es01:es01
restart: on-failure

@muyuto
Copy link
Author

muyuto commented Jul 14, 2021

Caused by: java.io.IOException: Function not implemented at sun.nio.fs.LinuxWatchService.(LinuxWatchService.java:64)

你的系统没有实现filewatch,换个os版本试试

你说的对,想了想还是拿官方Dockfile,确认里面的基础镜像为centos:8.3.2011,支持arm64,修改了一下不装libcurl(已内置,若装还有冲突),然后在apple mac m1环境下重新build了一个镜像,然后一切ok。

最后,谢谢指点。

踏实了

@muyuto muyuto closed this as completed Jul 14, 2021
@clstudy
Copy link

clstudy commented Jul 17, 2021

能否提供一下Dockfile

@yxm9264
Copy link

yxm9264 commented Aug 1, 2021

请问修改哪个文件的东西?

@zhusaidong
Copy link

请问修改哪个文件的东西?

https://github.com/nacos-group/nacos-docker/blob/master/build/Dockerfile

@yxm9264
Copy link

yxm9264 commented Aug 4, 2021

可以提供一下Dockfile

请问解决了吗?

@chuanleixu
Copy link

能否解决一下,docker 镜像 不支持apple M1 arm64架构的问题。

@zhusaidong
Copy link

zhusaidong commented Aug 5, 2021

@hiwangzi
Copy link

可以提供一下Dockfile

请问解决了吗?

可以这样改,hiwangzi/nacos-docker@6307130

或者直接用楼上打包的镜像,或者我打的这个也可以

docker run --name hello-nacos -e MODE=standalone -p 8848:8848 -d zill057/nacos-server-apple-silicon:2.0.3

@xkcoding
Copy link
Contributor

可以提供一下Dockfile

请问解决了吗?

可以这样改,zill057/nacos-docker@6307130

或者直接用楼上打包的镜像,或者我打的这个也可以

docker run --name hello-nacos -e MODE=standalone -p 8848:8848 -d zill057/nacos-server-apple-silicon:2.0.3

thanks a lot

@muyuto
Copy link
Author

muyuto commented Aug 30, 2021

能否提供一下Dockfile
我只是在官方的Dockfile基础上去除里脚本中要安装的libcurl,然后就可以了

@muyuto
Copy link
Author

muyuto commented Aug 30, 2021

请问修改哪个文件的东西?

#6340 (comment)
我只是在官方的Dockfile基础上去除里脚本中要安装的libcurl,然后就可以了

@muyuto
Copy link
Author

muyuto commented Aug 30, 2021

FROM centos:8.3.2011
MAINTAINER xxxx "xxxx@163.com"

set environment

ENV MODE="cluster"
PREFER_HOST_MODE="ip"
BASE_DIR="/home/nacos"
CLASSPATH=".:/home/nacos/conf:$CLASSPATH"
CLUSTER_CONF="/home/nacos/conf/cluster.conf"
FUNCTION_MODE="all"
JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk"
NACOS_USER="nacos"
JAVA="/usr/lib/jvm/java-1.8.0-openjdk/bin/java"
JVM_XMS="1g"
JVM_XMX="1g"
JVM_XMN="512m"
JVM_MS="128m"
JVM_MMS="320m"
NACOS_DEBUG="n"
TOMCAT_ACCESSLOG_ENABLED="false"
TIME_ZONE="Asia/Shanghai"

ARG NACOS_VERSION=2.0.2
ARG HOT_FIX_FLAG=""

WORKDIR $BASE_DIR

RUN set -x
&& yum update -y
&& yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel wget iputils nc vim
RUN wget https://github.com/alibaba/nacos/releases/download/${NACOS_VERSION}${HOT_FIX_FLAG}/nacos-server-${NACOS_VERSION}.tar.gz -P /home
RUN tar -xzvf /home/nacos-server-${NACOS_VERSION}.tar.gz -C /home
&& rm -rf /home/nacos-server-${NACOS_VERSION}.tar.gz /home/nacos/bin/* /home/nacos/conf/.properties /home/nacos/conf/.example /home/nacos/conf/nacos-mysql.sql
RUN yum autoremove -y wget
&& ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone
&& yum clean all

ADD bin/docker-startup.sh bin/docker-startup.sh
ADD conf/application.properties conf/application.properties
ADD init.d/custom.properties init.d/custom.properties

set startup log dir

RUN mkdir -p logs
&& cd logs
&& touch start.out
&& ln -sf /dev/stdout start.out
&& ln -sf /dev/stderr start.out
RUN chmod +x bin/docker-startup.sh

EXPOSE 8848
ENTRYPOINT ["bin/docker-startup.sh"]

@Keegan-y
Copy link

Thanks a lot. That solved my problem. @zill057

@Keegan-y
Copy link

Hi,That solved my problem:

docker pull zhusaidong/nacos-server-m1:2.0.3
docker run --name nacos-standalone -e MODE=standalone -e JVM_XMS=512m -e JVM_XMX=512m -e JVM_XMN=256m -p 8848:8848 -d zhusaidong/nacos-server-m1:2.0.3

@Keegan-y
Copy link

Hi,Thanks a lot.That solved my problem:

docker pull zhusaidong/nacos-server-m1:2.0.3
docker run --name nacos-standalone -e MODE=standalone -e JVM_XMS=512m -e JVM_XMX=512m -e JVM_XMN=256m -p 8848:8848 -d zhusaidong/nacos-server-m1:2.0.3

@zhusaidong

@mliang-circle
Copy link

@KomachiSion any interest in getting this fix into official nacos/nacos-server image?

@jujunchen
Copy link

Hi,Thanks a lot.That solved my problem:

docker pull zhusaidong/nacos-server-m1:2.0.3
docker run --name nacos-standalone -e MODE=standalone -e JVM_XMS=512m -e JVM_XMX=512m -e JVM_XMN=256m -p 8848:8848 -d zhusaidong/nacos-server-m1:2.0.3

@zhusaidong

2.X needs port 9848,right?

@AndyLau223
Copy link

Hi,That solved my problem:

docker pull zhusaidong/nacos-server-m1:2.0.3
docker run --name nacos-standalone -e MODE=standalone -e JVM_XMS=512m -e JVM_XMX=512m -e JVM_XMN=256m -p 8848:8848 -d zhusaidong/nacos-server-m1:2.0.3

Thanks, this also solve the issue on my macOS.

@lunasaw
Copy link

lunasaw commented Dec 8, 2022

Thanks, this also solve the issue on my macOS.

@redamancy-w
Copy link

在dockerfile里,把安装libcurl的代码删掉就好了

@zjh7890
Copy link

zjh7890 commented Mar 12, 2023

可以提供一下Dockfile

请问解决了吗?

可以这样改,hiwangzi/nacos-docker@6307130

或者直接用楼上打包的镜像,或者我打的这个也可以

docker run --name hello-nacos -e MODE=standalone -p 8848:8848 -d zill057/nacos-server-apple-silicon:2.0.3

老哥,造福人类哇

@shiyingyan
Copy link

太垃圾了, 阿里就不能适配下,build一个arm架构的镜像吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests