Package org.eclipse.mosaic.lib.docker
Class DockerRun
java.lang.Object
org.eclipse.mosaic.lib.docker.DockerRun
Provides methods to easily compose a "docker run" command.
-
Method Summary
Modifier and TypeMethodDescriptionSets user to current user/group.execute()
Executes the composed docker run command.Used to set the containers name.Adds an environmental parameter to the docker run command.portBinding
(int portHost, int portContainer) Adds an explicit port binding to this docker run command.Marks the docker container to be removed after it has been run.If containers with the same name are already running, this method marks those containers to be removed beforehand.Sets the user and group of container.volumeBinding
(File localDir, String volumePath) Adds an explicit volume binding this docker run command.
-
Method Details
-
name
Used to set the containers name.- Parameters:
name
- the name of the container
-
removeAfterRun
Marks the docker container to be removed after it has been run. -
removeBeforeRun
If containers with the same name are already running, this method marks those containers to be removed beforehand. -
portBinding
Adds an explicit port binding to this docker run command. If no port binding is defined, all exposed ports will be published to random ports on the host.- Parameters:
portHost
- the local port on the hostportContainer
- the exposed port within the container, as defined in the Dockerfile
-
user
Sets the user and group of container. See https://docs.docker.com/engine/reference/run/#user for details.- Parameters:
user
- the user and group as string accepted by Docker's CLI parameter "--user".
-
currentUser
Sets user to current user/group. -
volumeBinding
Adds an explicit volume binding this docker run command. The resulting container can then share files with the host.- Parameters:
localDir
- the local directory which should be bound with the containervolumePath
- the path within the container to be bound with
-
parameter
Adds an environmental parameter to the docker run command. Those parameters are then available in the running docker container. -
execute
Executes the composed docker run command.- Returns:
- The DockerContainer associated with this docker run command.
-