#reuse/clone container

1 messages · Page 1 of 1 (latest)

glacial mantle
#

If i build a container from a Dockerfile which holds initial tools so later i can run other commands from it. Lets say having php with required extensions pre installed. I want to be able to reuse that container to run different php tools like rector, phpstan, phpunit, etc. How can i reuse, clone; this container for this purpose. Notice i want to do it in parallel no run commands on top of each other

placid mountain
#

This should just work how you want, no clone or anything needed. e.g.

    ctr := dag.Container().Build(someDir)
    ctrA := ctr.WithExec([]string{"foo"})
    ctrB := ctr.WithExec([]string{"bar"})

ctrA and ctrB will be independent and not affect the original ctr or each other. Basically, you can think of Container and all the other types as immutable; when you call methods on them they are creating a new object.

(using Go syntax, but if it's confusing let me know and can give an example for other languages, they all have the same behavior though)