diff --git a/README.md b/README.md index 4268fb0..31a799b 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,10 @@ You can add the scripts to your images like this: FROM alpine ARG DOCKER_SCRIPTS_VERSION=0.2.0 -ADD --chmod=755 https://github.com/felipecrs/docker-scripts/raw/v${DOCKER_SCRIPTS_VERSION}/get_cpus.sh /opt/docker-scripts/ -ADD --chmod=755 https://github.com/felipecrs/docker-scripts/raw/v${DOCKER_SCRIPTS_VERSION}/get_memory.sh /opt/docker-scripts/ -ADD --chmod=755 https://github.com/felipecrs/docker-scripts/raw/v${DOCKER_SCRIPTS_VERSION}/is_privileged.sh /opt/docker-scripts/ +ADD https://github.com/felipecrs/docker-scripts/archive/refs/tags/v${DOCKER_SCRIPTS_VERSION}.tar.gz /opt/docker-scripts ``` -And then, you can invoke any script calling it from their path: +And then, you can invoke any script calling it from `/opt/docker-scripts`: ```console ❯ docker run --rm --cpus 2 my-image /opt/docker-scripts/get_cpus.sh @@ -39,23 +37,23 @@ And then, you can invoke any script calling it from their path: In a system with cgroup v2: ```console -❯ cat get_cpus.sh | docker run --rm -i -e VERBOSE=true alpine sh +❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true alpine sh VERBOSE(get_cpus.sh): cgroup v2 detected. VERBOSE(get_cpus.sh): No CPU limits set. VERBOSE(get_cpus.sh): CPUs: 16 -❯ cat get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 2 alpine sh +❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 2 alpine sh VERBOSE(get_cpus.sh): cgroup v2 detected. VERBOSE(get_cpus.sh): CPUs: 2 -❯ cat get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 1.5 alpine sh +❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 1.5 alpine sh VERBOSE(get_cpus.sh): cgroup v2 detected. VERBOSE(get_cpus.sh): CPUs: 1 -❯ cat get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 0.5 alpine sh +❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 0.5 alpine sh VERBOSE(get_cpus.sh): cgroup v2 detected. VERBOSE(get_cpus.sh): CPUs: 1 @@ -64,23 +62,23 @@ VERBOSE(get_cpus.sh): CPUs: Another system with cgroup v1: ```console -❯ cat get_cpus.sh | docker run --rm -i -e VERBOSE=true alpine sh +❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true alpine sh VERBOSE(get_cpus.sh): cgroup v1 detected. VERBOSE(get_cpus.sh): No CPU limits set. VERBOSE(get_cpus.sh): CPUs: 8 -❯ cat get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 2 alpine sh +❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 2 alpine sh VERBOSE(get_cpus.sh): cgroup v1 detected. VERBOSE(get_cpus.sh): CPUs: 2 -❯ cat get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 1.5 alpine sh +❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 1.5 alpine sh VERBOSE(get_cpus.sh): cgroup v1 detected. VERBOSE(get_cpus.sh): CPUs: 1 -❯ cat get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 0.5 alpine sh +❯ cat scripts/get_cpus.sh | docker run --rm -i -e VERBOSE=true --cpus 0.5 alpine sh VERBOSE(get_cpus.sh): cgroup v1 detected. VERBOSE(get_cpus.sh): CPUs: 1 @@ -91,13 +89,13 @@ VERBOSE(get_cpus.sh): CPUs: In a system with cgroup v2: ```console -❯ cat get_memory.sh | docker run --rm -i -e VERBOSE=true alpine sh +❯ cat scripts/get_memory.sh | docker run --rm -i -e VERBOSE=true alpine sh VERBOSE(get_memory.sh): cgroup v2 detected. VERBOSE(get_memory.sh): No memory limits set. VERBOSE(get_memory.sh): Memory (MB): 15996 -❯ cat get_memory.sh | docker run --rm -i -e VERBOSE=true --memory 1g alpine sh +❯ cat scripts/get_memory.sh | docker run --rm -i -e VERBOSE=true --memory 1g alpine sh VERBOSE(get_memory.sh): cgroup v2 detected. VERBOSE(get_memory.sh): Memory (MB): 1024 @@ -106,13 +104,13 @@ VERBOSE(get_memory.sh): Memory (MB): Another system with cgroup v1: ```console -❯ cat get_memory.sh | docker run --rm -i -e VERBOSE=true alpine sh +❯ cat scripts/get_memory.sh | docker run --rm -i -e VERBOSE=true alpine sh VERBOSE(get_memory.sh): cgroup v1 detected. VERBOSE(get_memory.sh): No memory limits set. Memory (MB): 32092 -❯ cat get_memory.sh | docker run --rm -i -e VERBOSE=true --memory 1g alpine sh +❯ cat scripts/get_memory.sh | docker run --rm -i -e VERBOSE=true --memory 1g alpine sh VERBOSE(get_memory.sh): cgroup v1 detected. VERBOSE(get_memory.sh): Memory (MB): 1024 @@ -121,12 +119,12 @@ VERBOSE(get_memory.sh): Memory (MB): ### `is_privileged.sh` ```console -❯ cat is_privileged.sh | docker run --rm -i -e VERBOSE=true alpine sh +❯ cat scripts/is_privileged.sh | docker run --rm -i -e VERBOSE=true alpine sh VERBOSE(is_privileged.sh): Container is not running in privileged mode. ❯ echo $? 1 -❯ cat is_privileged.sh | docker run --rm -i -e VERBOSE=true --privileged alpine sh +❯ cat scripts/is_privileged.sh | docker run --rm -i -e VERBOSE=true --privileged alpine sh VERBOSE(is_privileged.sh): Container is running in privileged mode. ❯ echo $? 0 diff --git a/get_cpus.sh b/scripts/get_cpus.sh similarity index 100% rename from get_cpus.sh rename to scripts/get_cpus.sh diff --git a/get_memory.sh b/scripts/get_memory.sh similarity index 100% rename from get_memory.sh rename to scripts/get_memory.sh diff --git a/is_privileged.sh b/scripts/is_privileged.sh similarity index 100% rename from is_privileged.sh rename to scripts/is_privileged.sh