Shiphelm
Table of Contents
- Shiphelm
- Installation
- Docker usage example
- Get a List of Running Containers
- Get a running container by ID
- Get Stats and Ports for a Container by ID
- Search for Containers by Name
- Change the Ports of a Container
- Rename a Container
- Add and Remove Containers from Networks
- Create and Delete Networks
- Run a New Container
- Get and Set Environment Variables for a Container
- Get and Set Volumes for a Container
- Example code
- Kubernetes (K8S) usage example
- Get a List of Running Containers
- Get Stats and Ports for a Container by ID
- Search for Containers by Name
- Change the Ports of a Container
- Rename a Container
- Add and Remove Containers from Networks
- Create and Delete Networks
- Run a New Container
- Get and Set Environment Variables for a Container
- Get and Set Volumes for a Container
- Example code
- Dynamic engine selection
- Remote engines via GUI
- Contributing
Shiphelm is a Python library for interacting with containers more easily. With Shiphelm, you can:
- Get a list of all running containers
- Get usage statistics and used ports for a given container by ID
- Search containers by name or ID
- Change the open ports of a container
- Run new containers
- Work with Docker, and Kubernetes
- Use Kubernetes clusters and Docker Swarm
- work on clusters, and swarms of container hosts
Installation
You can install Shiphelm using pip:
pip install shiphelm
PyPI: https://pypi.org/project/Shiphelm/
GitHub Releases https://github.com/Gameplex-Software/ShipHelm/releases
Docker usage example
This code will allow you to manage the local container engine
Standalone Docker installation
from shiphelm.helm import helm
hd = helm() # create an instance of helm
helm.set_engine_manual("docker")
Remote standalone Docker installation
This code will allow you to manage any compatible remote container engine
from shiphelm.helm import helm
hd = helm.reomte_connect('tcp://remote-docker-host:2375') # create an instance of helmdocker for romote management
Remote Docker swarm installation
from shiphelm.helm import helm
hd = helm.helm() # create an instance of helm
helm.set_engine_manual(engine_select="docker", remoteAddress="YOUR ADDRESS HERE", remoteSecurity=<True|False>)
Get a List of Running Containers
running_containers = hd.get_running_containers()
Get a running container by ID
get_container_by_id(container_id)
Get Stats and Ports for a Container by ID
container_stats = hd.get_container_stats(container_id)
container_ports = hd.get_container_ports(container_id)
Search for Containers by Name
containers_by_name = hd.search_containers(name)
Change the Ports of a Container
hd.change_container_ports(container_id, ports)
Rename a Container
hd.rename_container(container_id, new_name)
Add and Remove Containers from Networks
hd.add_container_to_network(container_id, network_name)
hd.remove_container_from_network(container_id, network_name)
Create and Delete Networks
hd.create_network(network_name)
hd.delete_network(network_name)
Run a New Container
container = hd.run_container(
image=image,
command=command,
detach=detach,
ports=ports,
environment=environment,
volumes=volumes
)
Get and Set Environment Variables for a Container
container_environment = hd.get_container_environment(container_id)
hd.set_container_environment(container_id, environment)
Get and Set Volumes for a Container
container_volumes = hd.get_container_volumes(container_id)
hd.set_container_volumes(container_id, volumes)
Example code
This example runs 4 instances of the Docker "Getting Started" container
from shiphelm.helmdocker import helmdocker
hd = helmdocker() # create an instance of helmdocker
container_list = hd.get_running_containers() # call the method on the instance
print(container_list)
w=0
print("Preparing new server...")
while w<3:
hd.run_container(image="docker/getting-started", detach=1)
w=w+1
print("Your server is up and ready for connection!")
Kubernetes (K8S) usage example
This code will allow you to manage the local container engine
from shiphelm.helm import helm
hd = helm.helm() # create an instance of helm
helm.set_engine_manual("kubernetes")
This code will allow you to manage any compatible remote container engine
from shiphelm.helm import helm
hd = helm.reomte_connect('tcp://remote--host:2375') # create an instance of helm for romote management
Get a List of Running Containers
running_containers = hd.get_running_containers()
Get Stats and Ports for a Container by ID
container_stats = hd.get_container_stats(container_id)
container_ports = hd.get_container_ports(container_id)
Search for Containers by Name
containers_by_name = hd.search_containers(name)
Change the Ports of a Container
hd.change_container_ports(container_id, ports)
Rename a Container
hd.rename_container(container_id, new_name)
Add and Remove Containers from Networks
hd.add_container_to_network(container_id, network_name)
hd.remove_container_from_network(container_id, network_name)
Create and Delete Networks
hd.create_network(network_name)
hd.delete_network(network_name)
Run a New Container
container = hd.run_container(
image=image,
command=command,
detach=detach,
ports=ports,
environment=environment,
volumes=volumes
)
Get and Set Environment Variables for a Container
container_environment = hd.get_container_environment(container_id)
hd.set_container_environment(container_id, environment)
Get and Set Volumes for a Container
container_volumes = hd.get_container_volumes(container_id)
hd.set_container_volumes(container_id, volumes)
Example code
This example runs 4 instances of the "Getting Started" container
from shiphelm.helm import helm
hd = helm() # create an instance of helm
container_list = hd.get_running_containers() # call the method on the instance
print(container_list)
w=0
print("Preparing new server...")
while w<3:
hd.run_container(image="ollyw123/helloworld", detach=1)
w=w+1
print("Your server is up and ready for connection!")
Dynamic engine selection
You may have noticed that the syntax for controling both Docker and Kubernetes are identical, the way the code you write for ShipHelm is run depends on the engine you selected last.
In the last example we used the follwing code to initilise ShipHelm, create an alias, and select a container engine:
from shiphelm.helm import helm
hd = helm.helm() # create an instance of helm
helm.set_engine_manual("kubernetes")
f you want your cod to be able to use either engine that it detects locally you can use the following code instead:
from shiphelm.helm import helm
hd = helm.helm() # create an instance of helm
helm.set_engine_auto()
Remote engines via GUI
To use remote engines you can use the following the examples above to connect programatically or use the below code to open a GUI configuration wizard:
from shiphelm.helm import helm
hd = helm.helm() # create an instance of helm
helm.remote_popup()
Contributing
If you would like to contribute to SkiffUI, please feel free to open a pull request or issue on the GitHub repository.
<script src="https://giscus.app/client.js" data-repo="Gameplex-Software/ShipHelm" data-repo-id="R_kgDOJGgWLg" data-category="General" data-category-id="DIC_kwDOJGgWLs4CVv98" data-mapping="pathname" data-strict="0" data-reactions-enabled="1" data-emit-metadata="0" data-input-position="bottom" data-theme="light" data-lang="en" data-loading="lazy" crossorigin="anonymous" async> </script>Metadata
Release files for Shiphelm 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Shiphelm-0.8.0.tar.gz | 12.0 kB | Without provenance | Details for Shiphelm-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Shiphelm-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for Shiphelm-0.8.0-py3-none-any.whl |
Total release size: 25.9 kB
Release files / Shiphelm-0.8.0.tar.gz
| Download URL | Shiphelm-0.8.0.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a14333c4a46c80e612a6ebae33b3bf39a253e8ca12749764445077abab23da88
|
|
BLAKE2b-256 checksum How to use checksums |
03b8f09975d562a4502db2e887f399a03e83f902d0cc5ef94bc47bc65fd816fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / Shiphelm-0.8.0-py3-none-any.whl
| Download URL | Shiphelm-0.8.0-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5963372bb847ab016ee7a5aab9e5d4dd922e33dbad1ac7ba497816393c9a94f
|
|
BLAKE2b-256 checksum How to use checksums |
22cac81da9f1b0c0b6218dc72099418a2534764728bf137885f5130eee2bea99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for Shiphelm 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.