Skip to content

Instantly share code, notes, and snippets.

@leapar
Created June 7, 2017 08:54
Show Gist options
  • Save leapar/89d6aa18345a132373ce7d9cebfe5552 to your computer and use it in GitHub Desktop.
Save leapar/89d6aa18345a132373ce7d9cebfe5552 to your computer and use it in GitHub Desktop.

问题

编译好的go执行程序,在alpine里面运行报错?

sh: ./tscenter: not found
ldd tscenter 
	/lib64/ld-linux-x86-64.so.2 (0x55cf1c7fb000)
	libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x55cf1c7fb000)
	libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x55cf1c7fb000)

是因为/lib64目录不存在

mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2

搞定

@leapar
Copy link
Author

leapar commented Jun 7, 2017

docker中跑go语言程序,推荐如下

  1. 在liteide里面编译出跨平台运行程序linux x86_64

  2. 采用如下Dockerfile跑该程序

FROM alpine:3.4
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
ADD tscenter /opt/bin/tscenter
ENV PATH /opt/bin:$PATH
CMD ["tscenter"]
  1. 最终程序只会有11M左右

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