0

I have created a docker image named ocp-install from the following dockerfile

    FROM registry.access.redhat.com/ubi8/ubi-minimal:latest

    ARG INSTALL_DIR=/root/install-dir

    ENV PATH $PATH:$INSTALL_DIR

    WORKDIR $INSTALL_DIR

    RUN microdnf update && \
        microdnf install -y yum findutils && \
        mkdir -p $INSTALL_DIR

    COPY ocp-install $INSTALL_DIR

    ENTRYPOINT ["/bin/bash", "/usr/bin/ocp-install"]

I have run the command docker run -it ocp-install create for installation.

And now i want to destroy the install using command docker exec -it <containerID> destroy , however it gives the following error

OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: \"destroy\": executable file not found in $PATH": unknown
AishwaryaK
  • 61
  • 2
  • 11
  • Do you need to explicitly uninstall anything, or is deleting the container enough? (I'd normally expect the image to contain everything it needs, and not do additional installation at startup time; can you `RUN ocp-install create`, omit the `ENTRYPOINT`, and set the `CMD` to actually run the installed program?) – David Maze Mar 05 '21 at 11:00
  • Actually, the purpose of creating the image is to allow installing as well as uninstalling. Since the image has `ENTRYPOINT` pointing to a script, it allows both. The problem I am facing is sometimes after installation is done, the container goes in a stopped state and starting the containing again to explicitly run `destroy` command somehow triggers the `create` – AishwaryaK Mar 05 '21 at 11:44
  • Where does it install it? What happens after it's installed? – David Maze Mar 05 '21 at 11:59
  • The create command installs a cluster and destroy command deletes it. There are executables stored in the workdir, however during the `create` it does not use the existing executables but downloads executables in the local directory. – AishwaryaK Mar 10 '21 at 05:01

1 Answers1

1

short answer:

exec runs a new command, destroy is the subcommand of ocp-install, so you have to specify the whole command:

docker exec -it <containerID> -- /usr/bin/ocp-install destroy

explanation

as https://docs.docker.com/engine/reference/builder/#entrypoint describe,

Command line arguments to docker run will be appended after all elements in an exec form ENTRYPOINT

ENTRYPOINT works for docker run but not docker exec

as https://docs.docker.com/engine/reference/commandline/exec/ describe,

The docker exec command runs a new command in a running container.

When you are trying the docker exec -it <containerID> destroy command, docker tried to run the command destroy instead of appending destroy args to ocp-install

PapEr
  • 815
  • 5
  • 16