Docker Community Forums

Share and learn in the Docker community.

Service won't start in container

(Delboyjay) #1

I’m new to docker and I’m trying to get Nexus3 running in a windows container.

My machine is running Windows 10 and I’m using:
Docker CE Version 17.03.1-ce-win12 (12058)
Channel: stable

I have the following DockerFile content.

FROM microsoft/nanoserver
#FROM microsoft/windowsservercore     # I also tried this as the base image in case something was missing that I needed.
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"]

The content folder tree looks something like this and is just the nexus3 download for windows that is already unzipped.

==> tree /A
    |   +---.install4j
    |   +---bin
    |   +---deploy
    |   +---etc
    |   +---jre
    |   +---lib
    |   +---public
    |   \---system

When the container is build, it says that the service in installed and is started. I have confirmed this using Get-Service nexus3. Here is the build output:

==> 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

So far so good. Now I run the image using the following command:

docker run -it nexus3 powershell

Now using the powershell terminal from inside the container I check to see if the service is running:

Get-Service nexus3

Which returns:

Status   Name               DisplayName
------   ----               -----------
Stopped  nexus3             nexus3

So I ran the following:

Start-Service nexus3

But it hates me! :wink:

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

Now correct me if i’m wrong here but I should have an administrator powershell inside the container, because of the docker run -it switch.

I also checked that the service was set to run automatically and it was fine:

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

Does anyone have any idea what I’m doing wrong here? The fact that the service starts on a build but fails to start when I run it suggests I’m missing something but I can’t figure it out.

(Dcmcsd) #2

Docker images doesn’t snapshot your running process, your RUN command just run during docker build phase, you need to specify the command to run when container started using CMD or ENTRYPOINT command like below:

Or you can create batch and write multiple start commands in that batch file.

Hope this will help!

(Lusasinagatullina) #3

Hi! I have the same problem. I tried to install the service in image and after starting the container from cmg and powerdhell. This did not work.
sc start RSDataQualityWorkerPool
[SC] StartService FAILED 87:

The parameter is incorrect.

sc queryex RSDataQualityWorkerPool

SERVICE_NAME: RSDataQualityWorkerPool
WIN32_EXIT_CODE : 0 (0x0)
WAIT_HINT : 0x7d0
PID : 0
Did you solve the problem?

(Delboyjay) #4


No, I gave up after a couple of days with no replies to this thread and used pre-made Linux images instead. Did you try dcmcsd’s answer above as this sounds like that could have been my problem?

(Lusasinagatullina) #5

Hi! No dcmcsd’s answer did not help, my container does not start with the ENTRYPOINT NET START instruction.
But I solved the problem. I create a service in the dockerfile

RUN powershell New-Service -Name “RSDataQualityWorkerPool” -BinaryPathName “C:\WWW\WinServices\RSDataQualityWorkerPool\RSDataQualityWorkerPool.exe”

and start it in the running container.

Start-Service -Name “RSDataQualityWorkerPool”

My service started successfully!