I have written a python script to run the commands to execute nerdctl shell commands using subprocess,
res = subprocess.run(
f"nerdctl --host '/host/run/containerd/containerd.sock' --namespace k8s.io commit {container} {image}",
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, executable='/bin/bash')
I'm running this python script inside a ubuntu container, When I sh inside the conatiner and run this script by passing arguments
python3 run_script.py b3425e7a0d1e image1
it executes properly, but when I run it using debug mode
kubectl debug node/pool-93oi9uqaq-mfs8b -it --image=registry.digitalocean.com/test-registry-1/nerdctl@sha256:56b2e5690e21a67046787e13bb690b3898a4007978187800dfedd5c56d45c7b2 -- python3 run_script.py b3425e7a0d1e image1
I'm getting the error
b'/bin/bash: line 1: nerdctl: command not found\n'
can some one help/suggest where it is going wrong?
run_script.py
import subprocess
import sys
container = sys.argv[1]
image = sys.argv[2]
res = subprocess.run(
f"nerdctl --host '/host/run/containerd/containerd.sock' --namespace k8s.io commit {container} {image}",
shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, executable='/bin/bash')
print(res)
Dockerfile
FROM ubuntu:latest
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
LABEL version="0.1.0"
RUN apt-get -y update
RUN apt-get install wget curl -y
RUN wget -q "https://github.com/containerd/nerdctl/releases/download/v1.0.0/nerdctl-full-1.0.0-linux-amd64.tar.gz" -O /tmp/nerdctl.tar.gz
RUN mkdir -p ~/.local/bin
RUN tar -C ~/.local/bin/ -xzf /tmp/nerdctl.tar.gz --strip-components 1 bin/nerdctl
RUN echo -e '\nexport PATH="${PATH}:~/.local/bin"' >> ~/.bashrc
RUN source ~/.bashrc