Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Container - How to commit a container

Tags:

docker

windows

I am running a windows container on Windows Server 2016 and have made some changes on the base image. Now want to commit it but when I run

docker commit <containerId> <imageName>

I get the following error

Error response from daemon: Windows does not support commit of a running container.

Wondering if anyone has a solution to this. How would you otherwise build your containers if committing is not possible?

like image 750
Hamid Shahid Avatar asked Oct 27 '25 08:10

Hamid Shahid


2 Answers

This now works, see this blog post for full info. All you have to do is stop the container and then use 'docker ps -a' to show all containers (even ones no longer running). Find the container you want to create the image from, then use the usual 'docker commit {containerid} {newimagename}'. Since it is no longer running, the commit will succeed and you will see the new image in the output of 'docker images ls'.

like image 191
Frank Avatar answered Oct 30 '25 09:10

Frank


This comes from daemon/commit.go

// It is not possible to commit a running container on Windows
if runtime.GOOS == "windows" && container.IsRunning() {
    return "", fmt.Errorf("Windows does not support commit of a running container")
}

As docker commit mentions:

By default, the container being committed and its processes will be paused while the image is committed.

But implementing pause resume for Windows is only now being done with PR 26795, and commit dd38389 for docker pause.
Commit could follow soon after that.

How would you otherwise build your containers if committing is not possible?

Committing is about saving a container as an image (or "building" an image), not about building a container.

like image 38
VonC Avatar answered Oct 30 '25 10:10

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!