This is because you use USER node at the end of Dockerfile to start sshd, which I guess you want to use node user to start npm.
But, the suggested way is to use root to start sshd & use node to start npm, you can see a famous project redis which use same solution here
Then, you needed to next fix:
- Delete
USER node at the end of Dockerfile before CMD.
Delete RUN chmod 0444 /etc/ssh/* in your dockerfile
Otherwise, it will reported next which make sshd not work:
Permissions 0444 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
Delete RUN echo 'PermitRootLogin=without-password' >> /etc/ssh/sshd_config, use next to replace:
RUN echo 'PermitRootLogin=yes' >> /etc/ssh/sshd_config
Add RUN apt-get install -y gosu in Dockerfile to install gosu which will later be used in entrypoint.sh
In entrypoint.sh, change exec "$@" to next:
exec gosu node "$@"
This will assure npm start still run with user node.
Then, you can see when start the container, the sshd works, you can use service ssh stop && service ssh start to restart the service if you needed, but as the container run sshd well now, I guess you no need to use this again.