Keep a Windows Container running in Docker Compose

By default, Docker is designed to run resources in a very optimized way without wasting CPU and RAM and when Docker detects that noting is running inside a container it will shut it down.

Today, I will show you how I keep a Windows Container running when using a Docker Compose and integrating a very simple command that will keep the container running.

I came across the need to do that when I was playing and testing all kind of configuration with Docker Compose and found that if nothing was running inside the container it stopped after a few seconds.

Command

To accomplish my task, I will use the command option inside my Docker-Compose file.

The full line can be seen below:

command: ping -t localhost

And you can see it inside my docker-compose file

And you can see the full code below.

version: "3.3"
services:
backend:
image: microsoft/nanoserver
command: ping -t localhost
ports:
- "80:80"
volumes:
- backend-data:c:\data
volumes:
backend-data:

About Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications using a YAML file to configure the application’s services.

Once the file Is created I can start all the services using a single command.

This blog post was first published on DeployContainers.com

 


Posted

in

by