fabric8io / docker-maven-plugin

Maven plugin for running and creating Docker images
https://dmp.fabric8.io
Apache License 2.0
1.87k stars 640 forks source link

How to - Run existing container in plugin execution #1307

Open paololazzari opened 4 years ago

paololazzari commented 4 years ago

Description

Let's say I execute the plugin twice. The second time I execute the plugin, I want to re-use the container which was created in the first execution.

How can I do that? Is it even possible? From the docs:

http://dmp.fabric8.io/#docker:start

This goal creates and starts docker containers.

I just want to start a container, not create a new one.

Info

docker-maven-plugin:0.31.0
Docker version 19.03.1
TechGnome commented 4 years ago

+1 for this. I'm working on a case where the image in question is an Oracle database that developers will be using. the plan is to create profiles in the pom that will allow them to build and start the container. On subsequent runs though, we want to re-use the same container so that they aren't losing their data/work stored in the data - nor do we want them to fill their drive up with containers that aren't being used. Just in my testing alone, I ended up with multiple containers. O.O

As it currently is, it creates and starts a new container every time. :P We're trying to keep it simple. currently, I've got it down to mvn install -Dbuild-db and that creates and starts up the database. It would be nice if we could also do mvn install -Dstart-db to simply re-start the container. Although in fairness, we could also just give them the commands for docker to lookup the ID and re-start it. But again, we're tyring to keep things simple and consolidated.