Azure Hybrid Worker Docker [英] Azure Hybrid Worker Docker

查看:70
本文介绍了Azure Hybrid Worker Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用以下网址提供的说明对Docker进行Azure混合工作:

I am currently trying to docker-ize a Azure Hybrid Worker using the instructions provided at:

https://docs.microsoft.com/en-us/azure/automation/automation-linux-hrw-install

我90%成功,但是当我尝试使用onboarding.py运行最后一步时,在文档指定的位置找不到脚本.基本上,在容器中的任何位置都找不到该文件.任何帮助都会很棒.

I am 90% successful however when I try to run the final step using onboarding.py the script is not found in the location specificied by the documentation. Basically the file is not found anywhere in the container. Any help would be great.

FROM ubuntu:14.04

RUN apt-get update && \
    apt-get -y install sudo

ENV user docker

RUN useradd -m -d /home/${user} ${user} && \
    chown -R ${user} /home/${user} && \
    adduser ${user} sudo && \
    echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER ${user}

#WORKDIR /home/${user}

RUN sudo apt-get -y install apt-utils && \
 sudo apt-get -y install openssl && \
 sudo apt-get -y install curl && \
 sudo apt-get -y install wget && \
 sudo apt-get -y install cron && \
 sudo apt-get -y install net-tools && \
 sudo apt-get -y install auditd && \
 sudo apt-get -y install python-ctypeslib

RUN sudo wget https://raw.githubusercontent.com/Microsoft/OMS-Agent-for-Linux/master/installer/scripts/onboard_agent.sh && \
sudo sh onboard_agent.sh -w <my-workplace-id> -s <my-workspace-key>

RUN sudo python /opt/microsoft/omsconfig/modules/nxOMSAutomationWorker/DSCResources/MSFT_nxOMSAutomationWorkerResource/automationworker/scripts/onboarding.py --register <arguments-removed-for-stackoverflow-post>

EXPOSE 443

推荐答案

尽管我不知道它仍然无法正常运行的确切原因,但我已经分享了一些进展.

Although I don't know the exact reason why it doesn't work yet, I have made some progress that I would like to share.

我一直在通过比较在VM上运行的centos和centos docker容器之间的差异来试验此问题.尽管我无法查明丢失的确切内容,但是我仍然能够将 onboarding.py 文件显示在centos Docker容器上.

I've been experimenting with this problem by comparing the differences between centos running on a VM and a centos docker container. Although I haven't been able to pinpoint the exact things that are missing, I was able to get the onboarding.py file to show up on a centos docker container.

首先,我要做的是创建一个文件,其中包含在最小centos VM上安装的软件包的列表.在我的docker文件中,我浏览此文件并安装每个软件包.我打算削减文件以查看其工作所需.

First what I did is create a file that has a list of packages that are installed on a minimal centos VM. In my docker file I run through this file and install each package. I plan to cut down the file to see what's necessary for this to work.

第二件事是您必须具有 systemd ,默认情况下未安装.这是我测试时的Docker映像的样子:

The second thing is you must have systemd, which is not installed by default. Here is what my docker image looks like while I'm testing:

FROM centos:7

RUN yum -y update && yum install -y sudo

RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;


ENV user docker
RUN useradd -m -d /home/${user} ${user}
RUN chown -R ${user} /home/${user}
RUN echo "docker ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER ${user}
WORKDIR /home/${user}

COPY ./install_packages .
RUN sudo yum install -y $(cat ./install_packages)

sudo wget https://raw.githubusercontent.com/Microsoft/OMS-Agent-for-Linux/master/installer/scripts/onboard_agent.sh

CMD ["/usr/sbin/init"]

之后,我使用 docker run 在本地运行我的容器并启动systemd: docker run -v/run -v/sys/fs/cgroup:/sys/fs/cgroup:ro -d container_id

After that I use docker run to run my container locally and start systemd: docker run -v /run -v /sys/fs/cgroup:/sys/fs/cgroup:ro -d container_id

然后我 exec 进入我的容器并运行板载脚本:

I then exec into my container and run the onboard script:

sudo sh onboard_agent.sh -w'xxx'-s'xxx'

完成后,有时您需要等待约5分钟才能看到丢失的文件夹.要尽快触发此操作,您需要运行以下命令:

After it's done, you sometimes need to wait about 5 minutes for the missing folders to appear. To trigger this to happen sooner, you need to run this command:

/opt/microsoft/omsagent/bin/service_control重新启动{OMS_WORKSTATION_ID}

我的理解是该命令将重新启动OMS代理,并且需要systemctl.

My understanding is this command will restart the OMS agent and it requires systemctl.

我了解这无法回答您的问题,即如何通过构建和运行容器来使它正常工作而不必远程访问它.我仍在努力,如果找到答案,我会通知您.

I understand this doesn't answer your question on how to get it working from building and running the container without having to remote into it. I'm still working on that and I'll let you know if I find an answer.

祝你好运.

这篇关于Azure Hybrid Worker Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆