Automating a Container run in Windows. using docker desktop 4.37 and

I’m very new to Docker. I followed the instructions here for my first container.
Blackvuesync is a python program, but it requires linux-only modules, so rather than re-writing it for Windows, I’ll use the Docker container.

First I installed Docker Desktop in Windows 10.
Then I edited the docker-compose.yml file to set the volumes and environment.
Then from a CMD prompt in the folder containing docker-compose.yml , I ran
docker-compose up -d

This ran successfully, and I can see the container running in Docker Desktop. I can select “details” and see the output of the python program.

Now I want to make it a scheduled task. I found I cannot simply run docker-compose up -d without Docker Desktop running first. That results in an error.

I read that Docker Desktop 4.37.1 supports commands like docker desktop stop and docker desktop stop

So I upgraded to DD 4.37.1. It runs, but I have a repeating pop-up error:

What is the problem and how do I solve it?

This is common when Docker Desktop is restarted, after the wsl integration is injected into a distribution with enabled wsl integration. In my experience restarting the WSL integration is sufficient to make it work again.

Since Docker Desktop provides the docker backend and the tools, you indeed need to start Docker Desktop before. Docker Desktop is aimed to be a tool for developers, to be used as part of your tool chain when developing or testing software. If you want to run 24/7 operations, you should consider running docker-ce on a Linux host (baremetal or vm), as it’s suited for this kind of tasks.

1 Like

This is popping up every 10 seconds, and none of the offered options stops it. I’ve got to fix it.

I checked my WSL setup, and I see I have three now:

>wsl -l -v
  NAME              STATE           VERSION
* Legacy            Stopped         1
  docker-desktop    Stopped         2
  Ubuntu-22.04      Stopped         1

Legacy is a leftover and can be removed. But how do I remove it?

I found this article that suggests:
wsl --unregister Legacy


C:\Data\DEV\BlackVue_Sync>wsl --unregister Legacy
Unregistering.
The operation completed successfully.

C:\Data\DEV\BlackVue_Sync>wsl -l -v
  NAME              STATE           VERSION
* docker-desktop    Stopped         2
  Ubuntu-22.04      Stopped         1

C:\Data\DEV\BlackVue_Sync>

That seems to have worked - I’m not sure how unregister is different than uninstall - I’d prefer to uninstall and remove all leftovers if possible. Ubuntu is the only one I want in addition to Docker

What I’d really like to do is start and run the docker container from a script, and never have a GUI window appear at all. I’d like any output from the program in the container to be saved as a log file, and operate in the background. I saw this article - is it the correct approach?

This is now a WSL question, not Docker anymore, but unregistering is the way to delete all data actually.

https://learn.microsoft.com/en-us/windows/wsl/faq#how-do-i-uninstall-a-wsl-distribution-

To remove a distribution from WSL and delete all of the data associated with that Linux distribution, run wsl --unregister <distroName> where <distroName> is the name of your Linux distro, which can be seen from the list in the wsl -l command.

Additionally, you can then uninstall the Linux distro app on your machine just like any other store application.

To learn more about wsl commands, see the article, Basic commands for WSL.

So unregistering is like deleting a docker container and all its related data, while uninstalling is like deleting the Docker image. Except it is WSL and not Docker.

I am not sure if its the cause, but I can imagine that Docker Desktop expects the distributions with wsl integration to use the same wsl version. The Ubuntu-22.04 distribution uses a wsl1 distribution.

You can convert a stopped distribution to version 2 like this:

wsl --set-version Ubuntu-22.04 2

If the state is not sopped, then you’ll need to terminate it before: wsl -terminate Ubuntu-22.04

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.