I just stumbled over this twitter post from Steve
And I asked myself the same question already some time ago. And guess what, this is super easy 😉
Stop and Commit the container you want to copy
You first need to stop your container you want to copy. If it is running of course 😉
This should not take too long.
After that you can use the “Docker commit” command to save the current state of this container to a new image.
docker commit <ContainerToCopy> backup:containertocopy
“backup:containertocopy” is the name of the new image. If you have the docker extension for vs code you will see your image in the side bar like that:
Create a new container from the image
I created a simple script with the New-BcContainerWizard for you to reuse. Note that you only need to pass your image name to the New-BCContainer command. The artifact url you dont need in this scenario 😉
$containerName = 'CopyOfSavedContainer' $password = 'P@ssw0rd' $securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force $credential = New-Object pscredential 'admin', $securePassword $auth = 'UserPassword' $licenseFile = 'PathToYourLicenseFile' New-BcContainer ` -accept_eula ` -containerName $containerName ` -credential $credential ` -auth $auth ` -imageName 'backup:containertocopy' ` -licenseFile $licenseFile ` -memoryLimit 8G ` -updateHosts
This also should speed up your container creation process a lot as nothing needs to be installed inside the container 😉
Thanks for reading!
One thought on “Can I copy my container?”
Thanx for the tip, Stefan.