none
is it possible to run in daemonized mode? RRS feed

  • Question

  • I'm having trouble getting windows container working in daemonized mode - "docker run -d"...

    everything works fine when I run in interactive mode, but when I try to run any batch file or process using -d then container starts but exits right away

    did anyone try that yet?

    Sunday, August 23, 2015 12:29 PM

Answers

  • It is working for me - so long as the process stays alive.  What are you trying to run?

    Just to verify I wrote a basic 'script' that outputs the time waits 1 min then outputs the time again - you can see the results:

    Starting the container
    C:\Users\taylorb>docker run -d windowsservercore powershell -command "& {[DateTime]::Now.ToShortTimeString();Start-Sleep -Seconds 61;[DateTime]::Now.ToShortTimeString()}"
    41f4ddcb0635b611ab20c9aeb7603a546337ec2baedc6f21f83ccec86a5ffb49

    Listing the running Containers
    C:\Users\taylorb>docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
    41f4ddcb0635        windowsserve        "powershell -command "   14 seconds ago      Up 3 seconds                            stoic_sammet

    Dumped the current log
    C:\Users\taylorb>docker logs 41f4ddcb0635b611ab20c9aeb7603a546337ec2baedc6f21f83ccec86a5ffb49
    7:17 PM

    waited a minute or so

    Listed containers - now it's exited...
    C:\Users\taylorb>docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
    41f4ddcb0635        windowsserve        "powershell -command "   29 seconds ago      Up 18 seconds                           stoic_sammet

    Dumped the logs - you can see both times outputed

    C:\Users\taylorb>docker logs 41f4ddcb0635b611ab20c9aeb7603a546337ec2baedc6f21f83ccec86a5ffb49
    7:17 PM
    7:18 PM


    -Taylor

    Wednesday, August 26, 2015 7:21 PM

All replies

  • Docker is already running as a daemon.  What is the exact docker command you are running?

    This posting is provided AS IS with no warranties, and confers no rights. You assume all risk for your use.

    Tuesday, August 25, 2015 6:00 AM
  • It is working for me - so long as the process stays alive.  What are you trying to run?

    Just to verify I wrote a basic 'script' that outputs the time waits 1 min then outputs the time again - you can see the results:

    Starting the container
    C:\Users\taylorb>docker run -d windowsservercore powershell -command "& {[DateTime]::Now.ToShortTimeString();Start-Sleep -Seconds 61;[DateTime]::Now.ToShortTimeString()}"
    41f4ddcb0635b611ab20c9aeb7603a546337ec2baedc6f21f83ccec86a5ffb49

    Listing the running Containers
    C:\Users\taylorb>docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
    41f4ddcb0635        windowsserve        "powershell -command "   14 seconds ago      Up 3 seconds                            stoic_sammet

    Dumped the current log
    C:\Users\taylorb>docker logs 41f4ddcb0635b611ab20c9aeb7603a546337ec2baedc6f21f83ccec86a5ffb49
    7:17 PM

    waited a minute or so

    Listed containers - now it's exited...
    C:\Users\taylorb>docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
    41f4ddcb0635        windowsserve        "powershell -command "   29 seconds ago      Up 18 seconds                           stoic_sammet

    Dumped the logs - you can see both times outputed

    C:\Users\taylorb>docker logs 41f4ddcb0635b611ab20c9aeb7603a546337ec2baedc6f21f83ccec86a5ffb49
    7:17 PM
    7:18 PM


    -Taylor

    Wednesday, August 26, 2015 7:21 PM
  • I pulled down the microsoft/iis image and it seemed to run fine in daemon mode.  i didn't specify a command, but it seemed to list powershell as the command.

    regards

    Thursday, August 27, 2015 11:49 AM
  • the behavior seems to be different between powershell and docker client

    - when you start containers with powershell they continue to run after start command exits so you can connect to it or run webserver in it without doing anything special (that works fine for me)

    - with docker the container will exit immediately after you run the docker run command - normally when using docker on linux this is where -d option comes in which will cause the container to run as deamon as long as the command specified in arguments doesn't exit I was not able to get this working as expected

    https://docs.docker.com/reference/run/#detached-d

    Thursday, August 27, 2015 2:36 PM
  • I was trying to execute batch file which run nginx - the batch file never exits

    also sometimes I was able to get it to stay running but never when calling another batch file

    I'll try with your command

    Thursday, August 27, 2015 2:39 PM