Docker Compose Translation ~ "-d" and "-it powershell"

Hello everyone,

I am trying to translate the commands I use to run two of my docker containers into a docker-compose.yml file, and I am almost finished. However, there are two commands that I can’t seem to figure out how to translate:

“-d” to keep the containers running in detached mode (or is this handled another way when using docker compose?"

“-it powershell” to keep one of my containers from auto terminating

For reference, here are the commands I use to run the containers individually:

docker run -d -p 1433:1433  -e ACCEPT_EULA=Y --name projectsap_container projectsap

docker run -p 1234:1234 --name projectportal_container -d -it projectportal powershell

And here is my docker-compose.yml thus far:

version: "3"
services:
    projectsap:
        build:
            context: ./projectsap
            dockerfile: Dockerfile
        ports:
            - "1433:1433"
        container_name: projectsap_container
        environment:
            - ACCEPT_EULA=Y
        entrypoint: -d
    projectportal:
        build:
            context: ./projectportal
            dockerfile: Dockerfile
        ports:
            - "1234:1234"
        depends_on:
            - "projectsap"
        container_name: projectportal_container
        entrypoint: -d
        command: ["powershell"]
networks:
    default:
        external:
            name: nat

I tried adding the following to the projects…

    projectsap:
        [...]
        entrypoint: -d
    projectportal:
        [...]
        entrypoint: -d
        command: ["powershell"]

…but “entrypoint: -d” only caused the following error:

Recreating projectsap_container ... error

ERROR: for projectsap_container Cannot start service projectsap: container 3aba3bc244f47142b757b8127c8ba181b97517e70d207e7b88ef997cf5e2d371 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"

CommandLine":"-d","WorkingDirectory":"C:\\","Environment":{"ACCEPT_EULA":"Y","attach_dbs":"[]","sa_password":"_","sa_password_path":"C:\\ProgramData\\Docker\\secrets\\sa-password","sql_express_download_url":"https://go.microsoft.com/fwlink/?linkid=829176"},"CreateStdInPi

pe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}

ERROR: for projectsap Cannot start service projectsap: container 3aba3bc244f47142b757b8127c8ba181b97517e70d207e7b88ef997cf5e2d371 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {"CommandLin

e":"-d","WorkingDirectory":"C:\\","Environment":{"ACCEPT_EULA":"Y","attach_dbs":"[]","sa_password":"_","sa_password_path":"C:\\ProgramData\\Docker\\secrets\\sa-password","sql_express_download_url":"https://go.microsoft.com/fwlink/?linkid=829176"},"CreateStdInPipe":true,"

CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}

ERROR: Encountered errors while bringing up the project.

…and the “command: [“powershell”]” didn’t seem to do anything at all: The projectportal_container still isntantly terminates when brought up through the docker-compose.yml as opposed to the docker run command (This one runs an Apache Server to access the data from the projectsap, or at least that’s what it’s supposed to do).

Can anyone please help me with this? I’ve been looking at the docker compose reference for hours but couldn’t figure out any way to make this work, and I’m sure there has to be a way.

Any help with this would be greatly appreciated.

Thanks in advance,
Kira Resari

Okay, I figured out a solution/workaround.

Turns out that you can just use ‘’-d’’ as part of ‘‘docker up’’, same as with ‘‘docker run’’, and that resolved the first part of this issue. It might be obvious once you know it, but I’m still new at this.

The second part was more complicated, and the way I resolved it is more of a workaround. If anyone has a better solution to this, please let me know.

The heart of the issue was that the ‘‘projectportal’’ didn’t have a ‘‘CMD’’ command inside its Dockerfile, and thus needed to be executed with something like it (I’m still not 100% certain how it works). At first I tried numerous ways of getting the actual Project Portal Apache server to work (see Run apache in Docker Windows container using parameters), but after that didn’t work, I used the following workaround instead and added the following ‘‘CMD’’ command to my Dockerfile:

CMD ping -t localhost

As I said, I’m pretty certain that’s not the best possible solution, but it works. If anyone knows a better way of doing this, please let me know.

Cheers,
Kira Resari