B
B
brezhitskiy422022-01-12 23:13:44
Docker
brezhitskiy42, 2022-01-12 23:13:44

Why does an error occur when starting a Docker container?

Hello. I have a simple Dockerfile:

FROM node:latest

RUN useradd --create-home --shell /bin/bash testuser

USER testuser

WORKDIR /home/testuser

CMD ['/bin/bash']

With it, I created an image - testhub/node-base:latest.

When I start the container (without the default command) docker run -it testhub/node-base:latestI get the error /bin/sh: 1: [/bin/bash]: not found.

If you pass the default command at startup /bin/bash, then everything is OK - docker run -it testhub/node-base:latest /bin/bash.

This is very strange, because the commands are the same. What could be the problem? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2022-01-13
@brezhitskiy42

replace quotes in Dockerfile__double__ :
CMD ["/bin/bash"]

docker build -t xxx -f Dockerfile  .
docker run -it xxx

[email protected]:~$ echo $SHELL
/bin/bash
[email protected]:~$ exit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question