update readme and no arguments print help

This commit is contained in:
Muayyad Alsadi 2019-09-03 00:19:07 +03:00
parent 2d3e29e6f6
commit 470f8a3851
8 changed files with 82 additions and 49 deletions

105
README.md
View File

@ -1,66 +1,95 @@
# podman-compose
# Podman Compose
A script to run `docker-compose.yml` using [podman](https://podman.io/),
doing necessary mapping to make it work rootless.
An implementation of `docker-compose` with [podman](https://podman.io/) backend.
The main objective of this project is to be able to run `docker-compose.yml` unmodified and rootless.
This project is aimed to provide drop-in replacement for `docker-compose`,
and it's very useful for certain cases because:
- can run rootless
- only depend on `podman` and Python3 and [PyYAML](https://pyyaml.org/)
- no daemon, no setup.
- can be used by developers to run single-machine containerized stacks using single familiar YAML file
For production-like single-machine containerized environment consider
- [k3s](https://k3s.io) | [k3s github](https://github.com/rancher/k3s)
- [MiniKube](https://minikube.sigs.k8s.io/)
- [MiniShift](https://www.okd.io/minishift/)
For the real thing (multi-node clusters) check any production
OpenShift/Kubernetes distribution like [OKD](https://www.okd.io/minishift/).
## NOTE
This project is still underdevelopment.
## Installation
Install latest stable version from PyPI:
```
pip install podman-compose
pip3 install podman-compose
```
Or latest stable version from GitHub:
```
pip install https://github.com/muayyad-alsadi/podman-compose/archive/master.tar.gz
```
pass `--user` to install inside regular user home without being root.
Or latest development version from GitHub:
```
pip install https://github.com/muayyad-alsadi/podman-compose/archive/devel.tar.gz
pip3 install https://github.com/containers/podman-compose/archive/devel.tar.gz
```
## Mappings
* `1podfw` - create all containers in one pod (inter-container communication is done via `localhost`), doing port mapping in that pod.
* `1pod` - create all containers in one pod, doing port mapping in each container.
* `identity` - no mapping.
* `hostnet` - use host network, and inter-container communication is done via host gateway and published ports.
* `cntnet` - create a container and use it via `--network container:name` (inter-container communication via `localhost`).
* `publishall` - publish all ports to host (using `-P`) and communicate via gateway.
## Examples
When testing the `AWX`, if you got errors just wait for db migrations to end.
### Working Example
*Tested on latest ``podman`` (commit `349e69..` on 2019-03-11).*
By using many containers on a single pod that shares the network (services talk
via localhost):
or
```
podman-compose -t 1podfw -f examples/awx3/docker-compose.yml up
curl -o /usr/local/bin/podman_compose https://raw.githubusercontent.com/containers/podman-compose/devel/podman_compose.py
chmod +x /usr/local/bin/podman_compose
```
Or by reusing a container network and `--add-host`:
or
```
podman-compose -t cntnet -f examples/awx3/docker-compose.yml up
curl -o ~/.local/bin/podman_compose https://raw.githubusercontent.com/containers/podman-compose/devel/podman_compose.py
chmod +x ~/.local/bin/podman_compose
```
Or by using host network and localhost works as follows:
## Basic Usage
We have included fully functional sample stacks inside `examples/` directory.
A quick example would be
```
podman-compose -t hostnet -f examples/awx3-hostnet-localhost/docker-compose.yml up
cd examples/busybox
podman-compose --help
podman-compose up --help
podman-compose up
```
### Work in progress
A more rich example can be found in [examples/awx3](examples/awx3)
which have
- A Postgres Database
- RabbitMQ server
- MemCached server
- a django web server
- a django tasks
When testing the `AWX3` example, if you got errors just wait for db migrations to end.
## Tests
Inside `tests/` directory we have many useless docker-compose stacks
that are meant to test as much cases as we can to make sure we are compatible
## How it works
The default mapping `1podfw` creates a single pod and attach all containers to
its network namespace so that all containers talk via localhost.
For more information see [docs/Mappings.md](docs/Mappings.md).
If you are running as root, you might use identity mapping.
```
podman-compose -t 1pod -f examples/awx3/docker-compose.yml up
```

View File

@ -734,12 +734,14 @@ class PodmanCompose:
parser = argparse.ArgumentParser()
self._init_global_parser(parser)
subparsers = parser.add_subparsers(title='command', dest='command')
subparsers.default = 'up'
for cmd_name, cmd in self.commands.items():
subparser = subparsers.add_parser(cmd_name, help=cmd._cmd_desc)
for cmd_parser in cmd._parse_args:
cmd_parser(subparser)
self.global_args = parser.parse_args()
if not self.global_args.command:
parser.print_help()
exit(-1)
return self.global_args
def _init_global_parser(self, parser):
@ -893,8 +895,9 @@ def compose_up(compose, args):
podman_args = container_to_args(compose, cnt,
detached=args.detach, podman_command=podman_command)
compose.podman.run(podman_args)
if args.no_start or args.detach: return
if args.no_start or args.detach or args.dry_run: return
# TODO: handle already existing
# TODO: if error creating do not enter loop
# TODO: colors if sys.stdout.isatty()
threads = []

View File

@ -1,7 +1,8 @@
#!/usr/bin/env bash
find . -name "*.pyc" -exec rm -rf {} \;
find . -name "__pycache__" -exec rm -rf {} \;
find . -name "*.orig" -exec rm -rf {} \;
find . -name "*.pyc" -delete
find . -name "__pycache__" -delete
find . -name "*.orig" -delete
rm -rf .cache/
rm -rf build/
rm -rf builddocs/

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
./scripts/uninstall.sh
./scripts/clean_up.sh
python setup.py register
python setup.py sdist bdist_wheel
python3 setup.py register
python3 setup.py sdist bdist_wheel
twine upload dist/*

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash
pip uninstall podman-compose -y
pip3 uninstall podman-compose -y
./scripts/clean_up.sh

View File

@ -6,7 +6,7 @@ try:
except:
readme = ''
version = '0.1.3'
version = '0.1.4'
setup(
name='podman-compose',
@ -31,7 +31,7 @@ setup(
keywords='podman, podman-compose',
author='Muayyad Alsadi',
author_email='alsadi@gmail.com',
url='https://github.com/muayyad-alsadi/podman-compose',
url='https://github.com/containers/podman-compose',
py_modules=['podman_compose'],
entry_points={
'console_scripts': [