Skip to content

Commit

Permalink
Merge pull request #96 from albertosottile/autoremove
Browse files Browse the repository at this point in the history
Add support for autoremove option --rm
  • Loading branch information
lavie authored Oct 25, 2022
2 parents 6fe690f + 6c60c14 commit 62dbd2d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This prints out what you need to run to get a similar container. You can do `$(r
--detach=true \
myrepo/redis:7860c450dbee9878d5215595b390b9be8fa94c89 \
redis-server --slaveof 172.31.17.84 6379

Feeding it the output of `docker inspect` also works:

```
Expand All @@ -35,7 +35,7 @@ docker inspect <container-name> | runlike --stdin

## Run without installing

`runlike` is packaged as a Docker image: [assaflavie/runlike](https://hub.docker.com/r/assaflavie/runlike/).
`runlike` is packaged as a Docker image: [assaflavie/runlike](https://hub.docker.com/r/assaflavie/runlike/).

```
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
Expand Down Expand Up @@ -102,13 +102,15 @@ Probably **shouldn't use this in production** yet. If you do, double check that
the host
--restart string Restart policy to apply when a
container exits (default "no")
--rm Automatically remove the container
when it exits
--runtime string Runtime to use for this container
-t, --tty Allocate a pseudo-TTY
-u, --user string Username or UID (format:
<name|uid>[:<group|gid>])
-v, --volume list Bind mount a volume
--volumes-from list Mount volumes from the specified
container(s)
container(s)
-w, --workdir string Working directory inside the container
```
Expand Down Expand Up @@ -211,8 +213,6 @@ Probably **shouldn't use this in production** yet. If you do, double check that
--read-only Mount the container's root
filesystem as read only
--rm Automatically remove the container
when it exits
--security-opt list Security Options
--shm-size bytes Size of /dev/shm
--sig-proxy Proxy received signals to the
Expand Down
1 change: 1 addition & 0 deletions fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ sudocker run -d --name runlike_fixture4 \

sudocker rm -f runlike_fixture5
sudocker run -d --name runlike_fixture5 \
--rm \
--link runlike_fixture4:alias_of4 \
--link runlike_fixture1 \
runlike_fixture
Expand Down
3 changes: 3 additions & 0 deletions runlike/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ def format_cli(self):
if self.get_fact("Config.Tty"):
self.options.append('-t')

if self.get_fact("HostConfig.AutoRemove"):
self.options.append('--rm')

parameters = ["run"]
if self.options:
parameters += self.options
Expand Down
3 changes: 3 additions & 0 deletions test_runlike.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def test_tty(self):
self.expect_substr('-t \\')
self.dont_expect_substr('-t \\', 2)

def test_autoremove(self):
self.expect_substr('--rm \\', 5)

def test_restart_always(self):
self.expect_substr('--restart=always \\')

Expand Down

0 comments on commit 62dbd2d

Please sign in to comment.