dtw52353 2019-03-02 06:28
浏览 159

带有Go的Docker代理

I'm trying to create a Jenkins Docker agent that has Go. The following is my Dockerfile.

After I build it, if I try: docker run myimage:0.0.1 go version returns the Go version, however if I try this, it doesn't find Go at all.

docker run --privileged --dns 9.0.128.50 --dns 9.0.130.50 -d -P --name slave myimage:0.0.1
docker ps ## grab the port number
ssh -p PORT_NUMBER jenkins@localhost

What am I missing in order to make Go available under the Jenkins user?

FROM golang:1.11.5-alpine

RUN apk add --no-cache \
bash \
curl \
wget \
git \
openssh \
tar

COPY ssh/*key /etc/ssh/
COPY skel/ /home/jenkins
COPY id_rsa /home/jenkins/.ssh/id_rsa
COPY id_rsa.pub /home/jenkins/.ssh/id_rsa.pub

RUN addgroup docker \
    && adduser -s /bin/bash -h /home/jenkins -G docker -D jenkins \
    && echo "jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
    && echo "jenkins:jenkinspass" | chpasswd \
    && chmod u+s /bin/ping \
    && chown -R jenkins:docker /home/jenkins \
    && mv /etc/profile.d/color_prompt /etc/profile.d/color_prompt.sh \
    && mv /bin/sh /bin/sh.bak \
    && ln -s /bin/bash /bin/sh

# Standard SSH port
EXPOSE 22

CMD ["/usr/sbin/sshd", "-D"]
  • 写回答

1条回答 默认 最新

  • dragon0023 2019-03-02 12:29
    关注

    If you run:

    docker run myimage:0.0.1 which go
    

    You will see that go executable in path /usr/local/go/bin/go

    If you connect as jenkins user via ssh and run /usr/local/go/bin/go version all work as well.

    Conclusion:

    1. Go installation provided as root user
    2. jenkins user added after go installed and haven't /usr/local/go/bin/go in his $PATH environment variable.

    Solution:

    1. Add /usr/local/go/bin/go to $PATH for user jenkins
    2. Use go executable with full path.
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料