运行Docker Windows映像时无法启动Sonatype Nexus3服务

我是新来的docker,我试图让Nexus3在Windows容器中运行。

我的机器运行的是Windows 10,我正在使用:Docker CE版本17.03.1-ce-win12(12058)频道:stable d1db126

我有以下DockerFile内容。

FROM microsoft/nanoserver #FROM microsoft/windowsservercore # I also tried this as the base image in case something was missing that I needed. EXPOSE 8081 ADD /content /nexus3 WORKDIR \\nexus3\\nexus-3.3.1-01-win64\\nexus-3.3.1-01\\bin RUN ["nexus.exe", "/install", "nexus3"] RUN ["nexus.exe", "/start", "nexus3"] RUN ["powershell", "-Command", "Get-Service", "nexus3"] 

内容文件夹树看起来像这样,只是已经解压缩的窗口的nexus3下载。

 B:\Docker\nexus\content ==> tree /A B:. \---nexus-3.3.1-01-win64 +---nexus-3.3.1-01 | +---.install4j | +---bin | +---deploy | +---etc | +---jre | +---lib | +---public | \---system \---sonatype-work 

当容器被构build时,它表示已经安装并正在启动的服务。 我已经使用Get-Service nexus3证实了这一点。 这是构build输出:

 B:\docker\nexus ==> docker build -t nexus3 . Sending build context to Docker daemon 222 MB Step 1/7 : FROM microsoft/nanoserver ---> 6c367cf4cb98 Step 2/7 : EXPOSE 8081 ---> Running in 047d556668ac ---> 6478e2faf841 Removing intermediate container 047d556668ac Step 3/7 : ADD /content /nexus3 ---> caacf937e885 Removing intermediate container cb601d94cd4a Step 4/7 : WORKDIR \\nexus3\\nexus-3.3.1-01-win64\\nexus-3.3.1-01\\bin ---> d0e1afd3d105 Removing intermediate container 201e369a32de Step 5/7 : RUN nexus.exe /install nexus3 ---> Running in 61516df89010 Installed service 'nexus3'. ---> bbfff0f34205 Removing intermediate container 61516df89010 Step 6/7 : RUN nexus.exe /start nexus3 ---> Running in ff274ef81a91 Service is already running. ---> ba20f07a47ce Removing intermediate container ff274ef81a91 Step 7/7 : RUN powershell -Command Get-Service nexus3 ---> Running in 3c8c767a56fd Status Name DisplayName ------ ---- ----------- Running nexus3 nexus3 ---> ef166720c132 Removing intermediate container 3c8c767a56fd Successfully built ef166720c132 

到现在为止还挺好。 现在我使用以下命令运行映像:

 docker run -it nexus3 powershell 

现在使用容器内部的powershellterminal,检查服务是否正在运行:

 Get-Service nexus3 Status Name DisplayName ------ ---- ----------- Stopped nexus3 nexus3 

所以我跑了以下,但它恨我! 😉

 Start-Service nexus3 Start-Service : Failed to start service 'nexus3 (nexus3)'. At line:1 char:1 + Start-Service nexus3 + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException + FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServiceCommand 

现在纠正我,如果我在这里错了,但我应该有一个pipe理器在容器内的PowerShell的,因为“docker运行-it”开关,因此这不应该是一个启动服务的权限问题。

我也检查了服务设置为自动运行,并没有问题:

 ==>$(Get-Service nexus3).StartType Automatic 

有谁知道我在做什么错在这里? 事实上,服务开始构build,但无法启动时,我运行它表明我错过了一些东西,但我无法弄清楚。

事实上,容器内的用户应该拥有pipe理权限,所以你可能想检查是否有其他东西像端口一样被阻塞。 我不熟悉Nexus,但是你知道在哪里可以find日志目录吗? 它可能会给你什么阻塞服务。

此外,许多公司已经开始在GitHub上玩容器,所以我通常会在那里寻找现有的图像。

事实上,快速谷歌search向我展示了这一点。 也许,这是你需要的?

https://hub.docker.com/r/sonatype/nexus/