Giter Site home page Giter Site logo

add "run" command about podman-compose HOT 9 OPEN

containers avatar containers commented on July 17, 2024 4
add "run" command

from podman-compose.

Comments (9)

muayyad-alsadi avatar muayyad-alsadi commented on July 17, 2024

it's now much easier to add more commands using @cmd_run(podman_compose, cmd_name, cmd_desc)

see CONTRIBUTING.md

from podman-compose.

muayyad-alsadi avatar muayyad-alsadi commented on July 17, 2024

@stefanb2 there are some missing features like passing custom -l and -e and -v.

please test

$ python3 podman-compose.py -f examples/busybox/docker-compose.yaml run -h
usage: podman-compose.py run [-h] [-d] [--name NAME] [--entrypoint ENTRYPOINT]
                             [-e KEY=VAL] [-l KEY=VAL] [-u USER] [--no-deps]
                             [--rm] [-p PUBLISH] [--service-ports] [-v VOLUME]
                             [-T] [-w WORKDIR]
                             service ...

create a container similar to a service to run a one-off command

positional arguments:
  service               service name
  command               comman and its args

optional arguments:
  -h, --help            show this help message and exit
  -d, --detach          Detached mode: Run container in the background, print
                        new container name.
  --name NAME           Assign a name to the container
  --entrypoint ENTRYPOINT
                        Override the entrypoint of the image.
  -e KEY=VAL            Set an environment variable (can be used multiple
                        times)
  -l KEY=VAL, --label KEY=VAL
                        Add or override a label (can be used multiple times)
  -u USER, --user USER  Run as specified username or uid
  --no-deps             Don't start linked services
  --rm                  Remove container after run. Ignored in detached mode.
  -p PUBLISH, --publish PUBLISH
                        Publish a container's port(s) to the host (can be used
                        multiple times)
  --service-ports       Run command with the service's ports enabled and
                        mapped to the host.
  -v VOLUME, --volume VOLUME
                        Bind mount a volume (can be used multiple times)
  -T                    Disable pseudo-tty allocation. By default `podman-
                        compose run` allocates a TTY.
  -w WORKDIR, --workdir WORKDIR
                        Working directory inside the container
$ python3 podman-compose.py -f examples/busybox/docker-compose.yaml run --rm redis /bin/sh -c 'cat /etc/passwd'
# podman run --rm -i --name=busybox_redis_tmp60155 --pod=busybox ...
root:x:0:0:root:/root:/bin/ash
bin:x:1:1:bin:/bin:/sbin/nologin
...
redis:x:999:1000:Linux User,,,:/home/redis:/sbin/nologin
0

if it's not detached I make it interactive so you can run /bin/sh
please tell me if this behaviour is correct

from podman-compose.

stefanb2 avatar stefanb2 commented on July 17, 2024

Looks like you beat me to the punch. I started to work on an implementation yesterday. Unfortunately your changes seem to have broken the script completely.

If I take HEAD (7e0a036) I can't get podman-compose.py run XXX to work at all: the command parser sees XXX as the command instead of run. If I checkout HEAD^ (eb72a71) then it seems podman-compose.py run XXX does what it is supposed to do.

But commit eb72a71 broke podman-compose.py -t identity up completely, so I can't really test your changes:

  File ".../podman-compose.py", line 364, in mount_desc_to_args
    mount_desc = mount_dict_vol_to_bind(compose, fix_mount_dict(mount_desc, srv_name, cnt_name))
  File ".../podman-compose.py", line 334, in mount_dict_vol_to_bind
    proj_name = compose.proj_name
AttributeError: 'PodmanCompose' object has no attribute 'proj_name'

Looks like a typo and that line should instead read:

    proj_name = compose.project_name

from podman-compose.

muayyad-alsadi avatar muayyad-alsadi commented on July 17, 2024

Looks like a typo and that line should instead read:

yes, I've fixed that typo.

from podman-compose.

mariushoch avatar mariushoch commented on July 17, 2024

I got this working, but only with #43

from podman-compose.

agriffis avatar agriffis commented on July 17, 2024

This works for me on master, but one note, it always tries to re-create the pod:

✸ docker-compose run app /bin/bash
podman pod create --name=search --share net -p 8000:8000
Error: unable to create pod: error adding pod to state: name search is in use: pod already exists
125
...snip...
root@6bed1a5d3f2d:/app# exit

from podman-compose.

westurner avatar westurner commented on July 17, 2024

Would this make exec easier to implement or would that need a separate implementation?

from podman-compose.

stacyharper avatar stacyharper commented on July 17, 2024

Got a prob with the run command

#!/bin/sh -x
#/entrypoint.sh

echo "$@"
exit 1
$ podman-compose run app foo bar
+ echo
+ exit 1

It seems my args are not passed to the entrypoint.

Is it a bug? Have I missed something?

from podman-compose.

muayyad-alsadi avatar muayyad-alsadi commented on July 17, 2024

I'll try to look at issue this weekend.

from podman-compose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.