-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdocker
executable file
·54 lines (52 loc) · 2.32 KB
/
docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
# This script delegates docker commands to podman while transforming
# a few in order to be compatibile with docker/jenkins workflow plugin
case "$1" in
'-v')
# Fake docker version (workaround for workflow plugin:
# see https://github.com/jenkinsci/docker-workflow-plugin/blob/490548c08416997ed0168c29ff3ea5f7bb06e963/src/main/java/org/jenkinsci/plugins/docker/workflow/WithContainerStep.java#L144
# and https://github.com/jenkinsci/docker-workflow-plugin/blob/490548c08416997ed0168c29ff3ea5f7bb06e963/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L247)
echo 'Docker version 18.06.1-ce, build e68fc7a'
;;
run)
# Inject oom-score-adj from host in order to run
# within container with limited resources
shift
OOMSCORE=$(cat /proc/self/oom_score_adj)
if [ "$1 $2 $3" = '-t -d -u' ]; then
# Remove user mapping (since already mapped;
# workflow plugin workaround, see https://github.com/jenkinsci/docker-workflow-plugin/blob/490548c08416997ed0168c29ff3ea5f7bb06e963/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L344)
shift 4
exec /usr/local/bin/podman run -t -d --oom-score-adj "$OOMSCORE" "$@"
else
exec /usr/local/bin/podman run --oom-score-adj "$OOMSCORE" "$@"
fi
;;
inspect)
# Convert {{.Image}} to {{.ImageID}} (workaround for docker compatibility / workflow plugin:
# see https://github.com/jenkinsci/docker-workflow-plugin/blob/490548c08416997ed0168c29ff3ea5f7bb06e963/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L344;
# also podman ignores errors: https://github.com/containers/libpod/pull/2181)
shift
if [ "$1" = '-f' -a "$2" = '{{.Image}}' ]; then
shift 2
exec /usr/local/bin/podman inspect -f '{{.ImageID}}' "$@"
else
exec /usr/local/bin/podman inspect "$@"
fi
;;
top)
# Convert ps format option (workaround for docker compatibility / workflow plugin:
# see https://github.com/jenkinsci/docker-workflow-plugin/blob/490548c08416997ed0168c29ff3ea5f7bb06e963/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java#L140)
shift
if [ "$2" = '-eo' ]; then
CONTAINERID="$1"
shift 2
exec /usr/local/bin/podman top "$CONTAINERID" $(echo "$@" | sed -E 's/,/ /g')
else
exec /usr/local/bin/podman top "$@"
fi
;;
*)
exec /usr/local/bin/podman "$@"
;;
esac