2018-09-24 - How to build a Container Image from inside a running Container

Motivation

I have several Docker accounts and only one Windows 10 "wincred", meaning only one account can be logged in at the same time. When I want to build and push container images from a different account than the one I am currently logged into, I also want to be able to build and push without switching accounts. And I want to do this from inside a running container.

Source code:

git clone https://bitbucket.org/geircode/Run_VisualStudioCode_in_a_container


First, you need to configure the "docker login" credentials.

Create a path outside the folde "Run_VisualStudioCode_in_a_container" named:

DockerSecrets/Run_VisualStudioCode_in_a_container/dockerloginpassword

and put the password inside the "dockerloginpassword" file. Yes, I know it's in cleartext, but that's my fast solution at the moment. It can be solved more securly, but for this POC it's almost ok.

Then:

  • Navigate to the folder: "/dockerbuild"
  • Double-click on the "docker-compose.up.bat" file, and this will create a Container that will build the Container Image of the parent folder.