Unable to run shell in my container

Viewed 5377

I want to dockerize my application and I want to run and enter my container in order to see whether packages were installed properly, files were copied, etc.

Here's my Dockerfile:

FROM node:8.6
RUN mkdir /app
WORKDIR /app
COPY .*.json .
COPY src/ .
USER node
RUN yarn global add @angular/cli
EXPOSE 4200

The problem is, I can't run my container via docker run:

docker run my-notes -it --rm ash

I see errors:

container_linux.go:262: starting container process caused "exec: \"-it\": executable file not found in $PATH"
docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "exec: \"-it\": executable file not found in $PATH".
ERRO[0000] error waiting for container: context canceled 

What am I doing wrong?

2 Answers

The issue is that you need to pass the docker options before the image name not after that:

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

I have answered this question here as well. Hope it helps.

The node image comes with sh, bash and dash.

If you want ash you can install the package, but it's just a symlink to /bin/dash so you can just run:

docker run -it --rm my-notes dash

To install the ash package, add the following to your Dockerfile

RUN set -uex; \
    apt-get update; \
    apt-get install ash; \
    apt-get 

Then ash/dash can be run with

docker run -it --rm my-notes ash
Related