Skip to main content

Create and launch docker containers on multiple hosts.

Project description

docker-launch

PyPI Python Test License

Create and launch docker containers on multiple hosts.

Features

This library provides:

  • SSH public key authentication checker and its set-up command
  • Launch multiple Docker containers on arbitrary host(s), via command line or Python script

Installation

pip install docker-launch

Usage

To check if SSH public key authentication to user@192.168.1.1 is enabled or not, run

>>> from docker_launch import check_connection
>>> check_connection("user@192.168.1.1")
True

or from command line,

$ docker-launch check user@192.168.1.1
OK

If the authentication hasn't been set-up, you can configure it via

$ docker-launch check user@192.168.1.1 --setup

Once the authentication is set-up, let's prepare configuration file path/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 spawn

  • ros:humble-ros-core container on the host machine, executing command env ROS_DOMAIN_ID=1 ros2 topic pub first std_msgs/msg/Float64 '{data: 123.45}'
  • ros:humble-ros-core container on user@172.29.1.2, executing command env ROS_DOMAIN_ID=1 ros2 topic pub /second std_msgs/msg/Float64 '{data: 123.45}'

by running

>>> from docker_launch import launch_containers
>>> launch_containers("path/to/config.toml", remove=True)

or

$ docker-launch up path/to/config.toml --rm

For the details of the options, see docker run documentation and Docker SDK's documentation.

Options of docker run command which docker-launch command and docker_launch.launch_containers() function doesn't support
  • --attach, -a
  • --cgroupns
  • --cidfile
  • --detach, -d (always True)
  • --detach-keys
  • --disable-content-trust
  • --env-file
  • --expose
  • --gpus
  • -h (use --hostname instead)
  • --interactive, -i
  • --ip
  • --ip6
  • --label-file
  • --link-local-ip
  • --log-driver
  • --log-opt
  • --mount
  • --net
  • --net-alias
  • --network
  • --network-alias
  • --no-healthcheck
  • --pull
  • --sig-proxy
  • --stop-timeout
  • --ulimit
  • -v (use --volume instead)
Options of Docker SDK's docker.containers.run function which docker-launch command doesn't support (docker_launch.launch_containers() function supports them)
  • auto_remove
  • device_requests
  • init_path
  • log_config
  • lxc_conf
  • mounts
  • nano_cpus
  • network
  • network_disabled
  • network_mode
  • stdin_open
  • stdout
  • stderr
  • stream
  • ulimits
  • use_config_proxy
  • version

Configuration File Spec

The configuration is described in TOML format.
Required fields are:

  • baseimg (string) - Name of the image from which the containers are created
  • command (string) - Command template to execute in each containers, with Python 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 },
]

Following option is to be implemented soon.

  • include (array of string) - Paths to additional configuration files

The 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 using Semantic Versioning.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docker-launch-0.1.1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

docker_launch-0.1.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file docker-launch-0.1.1.tar.gz.

File metadata

  • Download URL: docker-launch-0.1.1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.13 Linux/5.15.0-1017-azure

File hashes

Hashes for docker-launch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bafae3f5fc048f816876ff7c79826e2091d89d03529854844d42880cd9a2b152
MD5 200aaa5d9fa5c98bb3dbb7be55c80143
BLAKE2b-256 c0d53acf094255fe8cfb919189b5afac295d00f68cdf6d10735129a62db19406

See more details on using hashes here.

File details

Details for the file docker_launch-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: docker_launch-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.8.13 Linux/5.15.0-1017-azure

File hashes

Hashes for docker_launch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b72a3cddec6ef5bf1d02930433b3b284b42974de9622b5f77d85f5f204ec4b0
MD5 a0d7bfa8f88df3f48ecdd341cb88d7c9
BLAKE2b-256 1894a890d3f1038df9574db3706e9d1dbcb5a03de31e0af25a25b7f783786c14

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page