Package: docker-launch
docker-launchCreate and launch docker containers on multiple hosts.FeaturesThis library provides:SSH public key authentication checker and its set-up commandLaunch multiple Docker containers on arbitrary host(s), via command line or Python scriptInstallationpipinstalldocker-launchUsageTo check if SSH public key authentication touser@192.168.1.1is enabled or not, run>>>fromdocker_launchimportcheck_connection>>>check_connection("user@192.168.1.1")Trueor from command line,$docker-launchcheckuser@192.168.1.1
OKIf the authentication hasn't been set-up, you can configure it viadocker-launchcheckuser@192.168.1.1--setupOnce the authentication is set-up, let's prepare configuration filepath/to/config.toml[ros_topics]baseimg="ros:humble-ros-core"command="env ROS_DOMAIN_ID=1 ros2 topic pub {a} std_msgs/msg/Float64 '{{data: 123.45}}'"targets=[{a="first",__machine__="localhost"},{a="/second",__machine__="user@172.29.1.2"},]This will spawnros:humble-ros-corecontainer on the host machine, executing commandenv ROS_DOMAIN_ID=1 ros2 topic pub first std_msgs/msg/Float64 '{data: 123.45}'ros:humble-ros-corecontainer onuser@172.29.1.2, executing commandenv ROS_DOMAIN_ID=1 ros2 topic pub /second std_msgs/msg/Float64 '{data: 123.45}'by running>>>fromdocker_launchimportlaunch_containers>>>launch_containers("path/to/config.toml",remove=True)ordocker-launchuppath/to/config.toml--rmFor the details of the options, seedocker run documentationandDocker SDK's documentation.Options ofdocker runcommand whichdocker-launchcommand anddocker_launch.launch_containers()function doesn't support--attach,-a--cgroupns--cidfile--detach,-d(alwaysTrue)--detach-keys--disable-content-trust--env-file--expose--gpus-h(use--hostnameinstead)--interactive,-i--ip--ip6--label-file--link-local-ip--log-driver--log-opt--mount--net(onlybridge,none,host, andcontainer:<name|id>are supported)--net-alias--network(onlybridge,none,host, andcontainer:<name|id>are supported)--network-alias--no-healthcheck--pull--sig-proxy--stop-timeout--ulimit-v(use--volumeinstead)Options of Docker SDK'sdocker.containers.runfunction whichdocker-launchcommand doesn't support (docker_launch.launch_containers()function supports them)auto_removedevice_requestsinit_pathlog_configlxc_confmountsnano_cpusnetworknetwork_disabledstdin_openstdoutstderrstreamulimitsuse_config_proxyversionConfiguration File SpecThe configuration is described inTOMLformat.
Required fields are:baseimg(string) - Name of the image from which the containers are createdcommand(string) - Command template to execute in each containers, withPython style placeholder(positional placeholder e.g.{0}isn't supported)targets(array of table) - List of parameter tables for each containers, and special parameter__machine__The fields above must be grouped in a table.[table-name]baseimg="docker:image-name"command="command template with {placeholder}"targets=[{placeholder="this",__machine__="user@172.29.1.2"},{placeholder="that"},]A configuration file can have multiple tables[table-1]baseimg="docker:image-name"command="command template with {placeholder}"targets=[{placeholder="this",__machine__="user@172.29.1.2"},{placeholder="that"},][table-2]baseimg="docker:other-image"command="other command {parameter} with curly braces {{escaped}}"targets=[{parameter=100,__machine__="user@172.29.1.2"},{parameter=200},]Optional field:include(array of string) - Paths to additional configuration filesThe instruction must be declared at top level (not inside tables).include=["path/to/other/config.toml","/path/to/another/config.toml"][table-name]baseimg="docker:image-name"command="command template with {placeholder}"targets=[{placeholder="this",__machine__="user@172.29.1.2"},{placeholder="that"},]This library is usingSemantic Versioning.