Class DockerRun

java.lang.Object
org.eclipse.mosaic.lib.docker.DockerRun

public class DockerRun extends Object
Provides methods to easily compose a "docker run" command.
  • Method Details

    • name

      public DockerRun name(String name)
      Used to set the containers name.
      Parameters:
      name - the name of the container
    • removeAfterRun

      public DockerRun removeAfterRun()
      Marks the docker container to be removed after it has been run.
    • removeBeforeRun

      public DockerRun removeBeforeRun()
      If containers with the same name are already running, this method marks those containers to be removed beforehand.
    • portBinding

      public DockerRun portBinding(int portHost, int portContainer)
      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 host
      portContainer - the exposed port within the container, as defined in the Dockerfile
    • user

      public DockerRun user(String 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

      public DockerRun currentUser()
      Sets user to current user/group.
    • volumeBinding

      public DockerRun volumeBinding(File localDir, String volumePath)
      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 container
      volumePath - the path within the container to be bound with
    • parameter

      public DockerRun parameter(String key, Object value)
      Adds an environmental parameter to the docker run command. Those parameters are then available in the running docker container.
    • execute

      public DockerContainer execute()
      Executes the composed docker run command.
      Returns:
      The DockerContainer associated with this docker run command.