dongshi7350 2017-07-19 11:54
浏览 315

Dockerfile连接到ODBC(例如HPE Vertica)设置

I have a simple GO program which successfully connects to Vertica in my ubuntu server. I have setup the .dobc.ini and odbc drvier in this ubuntu.

db, err := sql.Open("odbc", "DSN=HPVerticaDSN")
if err != nil {
    log.Fatal(err)
}

log.Println("DB ping started...")
if err = db.Ping(); err != nil {
    log.Fatalf("DB ping failed with error...%v", err)
}
log.Println("DB connected.")
defer db.Close()

Now, How do I setup the Dockerfile to run this in docker container. Is it possible to use light weight base image like alpine or we have to use ubuntu base image. Any examples would be greatly appreciated.

Here is my Dockerfile

FROM alpine:latest
MAINTAINER Prataksha Gurung <prataksha.gurung@mydomain.net>
RUN apk add --no-cache ca-certificates
ADD libverticaodbc.so /libverticaodbc.so
ADD .odbc.ini ~/.odbc.ini
ADD main /usr/bin/main
ENTRYPOINT ["main"]

and I am getting

panic: standard_init_linux.go:178: exec user process caused "no such file or directory" [recovered]
panic: standard_init_linux.go:178: exec user process caused "no such file or directory"

when I run this container.

  • 写回答

1条回答 默认 最新

  • dongxixiu9134 2017-07-20 13:51
    关注

    Finally I managed it to work with this dockerfile:

    FROM ubuntu:artful
    MAINTAINER Prataksha Gurung <prataksha.gurung@mydomain.net>
    RUN apt-get update
    RUN apt-get install -y curl
    #downloading the relevant linux driver for this docker environment
    RUN curl -O https://my.vertica.com/client_drivers/8.1.x/8.1.1-0/vertica-client-8.1.1-0.x86_64.tar.gz
    RUN ls -la
    RUN tar vzxf vertica-client-8.1.1-0.x86_64.tar.gz && rm vertica-client-8.1.1-0.x86_64.tar.gz
    RUN apt-get install -y unixodbc-dev
    ADD .odbc.ini /root/.odbc.ini         #-->your custom DSN setup
    ADD vertica.ini /root/vertica.ini     #-->extra odbc driver setup
    ADD main /usr/bin/main                #-->binary executable
    ENTRYPOINT ["main"]
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题