How come I get the following error when I run (in Windows 10):
>> docker run --rm --entrypoint "/bin/bash -c" rockylinux:8 uname
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/bin/bash -c": stat /bin/bash -c: no such file or directory: unknown.
It suggests there is no /bin/bash. But running this shows that there is a /bin/bash:
>> docker run --rm rockylinux:8 ls -al /bin/bash
-rwxr-xr-x 1 root root 1150560 Aug 2 2022 /bin/bash
You are misreading the error. It’s treating
/bin/bash -c as a file name. You will need to use ENTRYPOINT and/or CMD as a way to not only run bash, but also pass arguments.
Ok Thank you! I get it now. The problem I’m trying to solve is that I have built an image based on rockylinux:8 were I am installing node 18.17.1 using nvm (see dockerfile 1 below). I’m using this image to build nodejs native packages with napi to be served as a REST api with express. This is done in an interactive “shell”-mode (in a cicd pipeline). There I have access to the version of node that was installed.
But since it is a native application I also need a rockylinux:8 based image to run and serve those packages. So I want to build an executable image that starts the express server built on that same image (see dockerfile 2 below). When this image is run in executable mode, the container does not use the shell environment that I was in when building it. “npm -v” and “node -v” shows the old versions that comes with rocky8 (v10.24.0). In order to use node 18.17.1, I need to run “npm install” prefixed with with “/bin/bash -c -l” and use a CMD with “/root/.nvm/versions/node/v18.17.1/bin/node” instead of just “node”. When I run it interactively with -it I get into the shell environment and all works fine.
This is not a huge problem, but I’m want to learn if there is a way to run the image in an executable mode and get into the same shell environment that you do when you run it interactively.
dockerfile 1, used to produce an image /user/napi-build-rocky8:
RUN dnf install epel-release -y
RUN dnf install cmake3 gcc gcc-c++ make -y;
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash &&\
source ~/.bashrc &&\
nvm install 18.17.1 &&\
nvm use 18.17.1 &&\
npm install -g node-gyp node-addon-api
dockerfile 2 (based on the image built in dockerfile 1):
COPY . .
RUN /bin/bash -c -l "npm install"
CMD [ "/root/.nvm/versions/node/v18.17.1/bin/node", "server.js" ]```