首页 > 解决方案 > 将程序转换为 docker 容器

问题描述

我正在尝试转换此程序:

下载JetAdvice Edge

完整的安装指南可以在这里看到

从安装到 linux 机器,再到 Docker 容器。

我需要多个运行实例,而且我在业余时间一直在使用 Docker,现在终于可以在我的工作中使用了!

当我构建它时,我已经完成了dockerfile(我认为),它下载并安装了它需要的东西,并且构建完成没有问题。

但是,我无法运行 JetAdvice 程序/服务!我读过,如果我想在一个容器中运行多个东西,我应该使用主管,并且由于 JetEdge 程序有 3 个正在运行的服务,我正在使用它。

这是我的码头文件:

FROM ubuntu

MAINTAINER me

EXPOSE 33322
COPY startup.sh /opt/scripts/startup.sh
RUN apt-get update && \
    apt-get install -y apt-utils wget libunwind8 icu-devtools supervisor 
RUN mkdir -p -- /var/log/supervisor /opt/print/download /opt/print/edgeinstaller /opt/scripts

RUN wget https://app.jetadvice.com/install/edge/jetadvice-edge-linux-x64.tar -P /opt/print/download && \
    tar -xvf /opt/print/download/jetadvice-edge-linux-x64.tar -C /opt/print/edgeinstaller

RUN chmod +x /opt/print/edgeinstaller/Installer && \
    /opt/print/edgeinstaller/Installer install

RUN chmod +x /usr/bin/JetAdvice/Edge/Edge && \
    chmod +x /usr/bin/JetAdvice/Updater/Updater && \
    chmod +x /usr/bin/JetAdvice/EdgeUI/EdgeUi && \
    chmod +x /opt/scripts/startup.sh

COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

CMD ["/opt/scripts/startup.sh"]

这是我的supervisord.conf

[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid

[program:JetAdvice-Edge]
command=/usr/bin/JetAdvice/Edge/Edge

[program:JetAdvice-Updater]
command=/usr/bin/JetAdvice/Updater/Updater

[program:JetAdvice-Edge-UI]
command=/usr/bin/JetAdvice/EdgeUI/EdgeUi

和 startup.sh 脚本:

#!/bin/sh
#somethingvariblehere
/usr/bin/supervisord

我尝试了多种方式运行 JetAdvice,但我无法让程序运行。

有关信息,这是 JedAdvice-Edge.service 文件之一:

Description=JetAdvice Edge connector service
Wants=network.target
After=syslog.target network-online.target

[Service]
Type = simple
ExecStart=/usr/bin/JetAdvice/Edge/Edge
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

如果我登录到我的 docker 容器并尝试运行该服务,我会收到此错误

root@6727e8f42044:/# service JetAdvice-Updater start
JetAdvice-Updater: unrecognized service

如果我尝试直接运行程序,我会得到:

root@6727e8f42044:/# /usr/bin/JetAdvice/Edge/Edge
bash: /usr/bin/JetAdvice/Edge/Edge: Permission denied
root@6727e8f42044:/# ./usr/bin/JetAdvice/Edge/Edge
bash: ./usr/bin/JetAdvice/Edge/Edge: Permission denied

我尝试在 /usr/bin/JetAdvice/Edge/Edge 上执行 chmod +x ,然后程序似乎运行了 3 秒,然后什么也没有发生。

root@6727e8f42044:/# chmod +x /usr/bin/JetAdvice/Edge/Edge
root@6727e8f42044:/# /usr/bin/JetAdvice/Edge/Edge
root@6727e8f42044:/#

我什至不接近 linux 专家,但我无法想象我正在尝试做的事情,无法完成。那么我做错了什么,下一步是什么?

来自 JetEdge 团队的工作 install.json 文件

{
  "InstallConfig": {
    "ApiClient": {
      "SignIn": {
        "InstallKey": "prettykeyhere",
        "DcaInstanceID": "prettyidhere"
      },
      "HttpLogging": {
        "MaxSize": 10240,
        "LogHttp": false
      },
      "Proxy": {
        "Address": "",
        "Port": 8080,
        "AutoDetect": true
      }
    },
    "ApiEndpoint": {
      "LoginBaseAddress": "https://auth.eu.edge-api.com",
      "BaseAddress": "https://dr.eu.edge-api.com",
      "ConfigBaseAddress": "https://config.eu.edge-api.com",
      "StayAliveBaseAddress": "https://p.eu.edge-api.com",
      "UpdateBaseAddress": "https://upd.eu.edge-api.com",
      "UiApiBaseAddress": "https://ui.eu.edge-api.com",
      "RangesBaseAddress": "https://ranges.eu.edge-api.com",
      "LoggerBaseAddress": "https://log.eu.edge-api.com",
      "StatusBaseAddress": "https://status.eu.edge-api.com"
    },
    "Installs": [
      {
        "Product": 1,
        "Folder": "C:\\Program Files (x86)\\JetAdvice\\Updater",
        "ServiceName": "JetAdvice-Updater",
        "ServiceExe": "Updater.dll",
        "Version": "0.4.18.0",
        "BuildRID": "win-x86",
        "Oem": 0
      },
      {
        "Product": 10,
        "Folder": "C:\\Program Files (x86)\\JetAdvice\\Edge",
        "ServiceName": "JetAdvice-Edge",
        "ServiceExe": "Edge.dll",
        "Version": "0.4.24.0",
        "BuildRID": "win-x86",
        "Oem": 0
      },
      {
        "Product": 20,
        "Folder": "C:\\Program Files (x86)\\JetAdvice\\EdgeUI",
        "ServiceName": "JetAdvice-Edge-UI",
        "ServiceExe": "EdgeUi.dll",
        "Version": "0.4.1.0",
        "BuildRID": "win-x86",
        "Oem": 0
      }
    ]
  }
}

我为测试生成的密钥是: 4809b732-eb36-413f-8993-bd8d1f2e2942

编辑,我已经更新了 dockerfile,并将 startup.sh 脚本添加到了 OP。

标签: dockerdockerfilesupervisord

解决方案


我稍微修改了你的 Dockerfile。

FROM ubuntu:20.04

EXPOSE 33322

RUN apt-get update && \
    apt-get install -y apt-utils wget libunwind8 icu-devtools supervisor 

#RUN apt-get install -y systemctl
#RUN apt-get install -y systemd

RUN mkdir -p -- /var/log/supervisor /opt/print/download /opt/print/edgeinstaller

RUN wget https://app.jetadvice.com/install/edge/jetadvice-edge-linux-x64.tar -P /opt/print/download && \
    tar -xvf /opt/print/download/jetadvice-edge-linux-x64.tar -C /opt/print/edgeinstaller && \
    chmod +x /opt/print/edgeinstaller/Installer && \
    /opt/print/edgeinstaller/Installer install
    
RUN chmod +x /usr/bin/JetAdvice/Edge/Edge
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

CMD ["/usr/bin/supervisord"]

我添加了这一行 RUN chmod +x /usr/bin/JetAdvice/Edge/Edge来将 +x 添加到可执行文件中。

现在,当我启动容器时,它给了我一个错误,它停止了supervisord. 在/usr/share/JetAdvice/Edge/LogFiles您可以找到JetAdvice Edge日志下显示此错误

install.json - 缺少安装密钥。(参数“安装密钥”)

在 EF.JA.Edge.Service.Windows.Program.<>c.b__2_3(HostBuilderContext hostContext, IServiceCollection services) 在 Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() 在 Microsoft.Extensions.Hosting.HostBuilder.Build() 在EF.JA.Edge.Service.Windows.Program.Main(String[] args)

我在install.json下面找到了文件/usr/share/JetAdvice/Edge/Config/Shared,里面有InstallKeyjson 字段

{
  "InstallConfig": {
    "ApiClient": {
      "SignIn": {
        "InstallKey": "",
        "DcaInstanceID": "e5860224-12a6-429e-b931-86c50a7a5900"
      },
[..]
}

我在谷歌上找到了这个关于 JetAdvice 的网站,其中说:

下载 JetAdvice Edge 并生成安装密钥

我没有帐户,但我想您必须生成密钥并设置 install.json。


推荐阅读