Like “make” for Docker
I am working add wrapping my application in a docker container, which leads my to type some pretty verbose commands pretty often:
sudo docker build -t foo/bar . sudo docker run foo/bar /bin/bash /path/to/my/script/test_report.sh ...
I want some way to wrap these in a script, making them easier to execute, and letting me forget the details between runs.
Make does this pretty well. Instructions can be wrapped together, so I can do
make deploy or whatever.
I suppose there is nothing stopping me from just using make, but is there a more modern solution, that doesn’t break when I use spaces instead of tabs and is just more pleasant to work with?
My project is Python, but I am looking for a generic solution. Preferably one that lets me wrap bash scripts (since that allows me infinite flexibility)
2 Solutions collect form web for “Like “make” for Docker”
Take a look at docker-compose.
If you create the following docker-compose.yml file in the same folder as your Dockerfile:
foobar: build: . command: /bin/bash /path/to/my/script/test_report.sh
you can then build with:
and start a new container with :
What’s interesting with Docker compose is that you can define in the compose file anything related to the docker run command such as volumes, published ports, etc.
For more info take a look at the Docker compose documentation and file reference.
dobi is designed to be exactly that tool. A “build automation” tool that uses containers for all the tasks. Everything is configured in a yaml file, and you can run tasks like you would with