Windows automated batch file for building of docker images - windows

You might say why you want to automate that? Because I'm tired to update 4-5 repos every week and push them manually in Docker. So I want to use a simple windows batch-file to automate that.
I got my Dockerfile and my commands:
docker build -t project .
docker tag project repo/project:tag
docker push repo/project:tag:project
The problem I have is that for example the build command needs a bit time and the commands should only be called when the immediate predecessor is done.
START /B
somehow did not work.

Related

Docker on windows generates different image layer id for COPY command

Environment:
Docker on windows
Code in questions: COPY configure_my_app.bat .
Expected: If I run docker build multiple times, I expect the image id to be same from various runs on docker build, given that there is no change in the Dockerfile
What happens: The image id after the above command changes for each run of docker build
I read it somewhere a while ago that this might have something to do with file attributes/permissions. I wonder, how can I get around this ? I want to use layers from cache if Dockerfile is not changed.

How to automatically fetch the active Docker registry

I am delivering a Docker image along with a script to automate and build > push that image to the repository.
docker build -t myDockerSpace/myServiceImage:latest .
docker push myDockerSpace/myServiceImage
without specifying the namespace/hub I run into access issues. Anyhow issue is when I delivery these scripts I would need to ask them to manually change the hub to their respective registry and then run which actually kills the purpose to automate it.
Is there a way I can fetch and insert the active Docker namespace of the machine where it is running and insert it in the document?

File-not-found-Error when building/runing my very dockerfile that should start a batch-file

Hi I am new to docker containers and want to build and run a simple container which should then start a small batchfile. I am using docker desktop. / win 10. Everything is located in the same directory:
C:\DockerTestGUI\Versionen\Dockerrunsbatch
This is my batch-File I want to run in the end:
This is my dockerfile, just 1 line since I do not have to copy anything from DockerHub:
I build my image like that :
docker build -t simpleimage
When I try to run my Image I get this "not-found-error" :
Can anybody help me on this please?
You have used wrong image ubuntu:latest. It will use to execute shell scripts (*.sh) not batch files.
For batch file execution you need Windows image.
Here's initial Dockerfile:
FROM mcr.microsoft.com/windows/servercore:1803
CMD C:\DockerTestGUI\Versionen\Dockerrunsbatch\TestMessage.bat && cmd
Here, I have changed image name and associated version.
I have used tag 1803 as my host system version is Windows 10 (10.0.17134).
You can choose with your windows version and then apply relevant tag.
Tags are listed in this link : https://hub.docker.com/_/microsoft-windows-servercore

Best way for debugging docker build error

I am trying to build docker image from the dockerfile and currently let's say I have 20-30 commands. And if my build fail in error in 25th command I again have to run the whole build process from the start.
Is there any right solution for building docker containers?

Simple docker deployment tactics

Hey guys so I've spend the past few days really digging into Docker and I've learned a ton. I'm getting to the point where I'd like to deploy to a digitalocean droplet but I'm starting to wonder about the strategy of building/deploying an image.
I have a perfect Dev setup where I've created a file volume tied to my app.
docker run -d -p 80:3000 --name pug_web -v $DIR/app:/Development test_web
I'd hate to have to run the app in production out of the /Development folder, where I'm actually building the app. This is a nodejs/express app and I'd love to concat/minify/etc. into a local dist folder ane add that build folder to a new dist ready image.
I guess what I'm asking is, A). can I have different dockerfiles, one for Dev and one for Dist? if not B). can I have if statements in my docker files that would do something like... if ENV == 'dist' add /dist... etc.
I'm struggling to figure out how to move this from a Dev environment locally to a tightened up production ready image without any conditionals.
I do both.
My Dockerfile checks out the code for the application from Git. During development I mount a volume over the top of this folder with the version of the code I'm working on. When I'm ready to deploy to production, I just check into Git and re-build the image.
I also have a script that is executed from the ENTRYPOINT command. The script looks at the environment variable "ENV" and if it is set to "DEV" it will start my development server with debugging turned on, otherwise it will launch the production version of the server.
Alternatively, you can avoid using Docker in development, and instead have a Dockerfile at the root of your repo. You can then use your CI server (in our case Jenkins, but Dockerhub also allows for automated build repositories that can do that for you, if you're a small team or don't have access to a dedicated build server.
Then you can just pull the image and run it on your production box.

Resources