I have a docker file as below.
launch.sh is the entry point in this docker image.
FROM ubuntu:16.04 USER root RUN apt-get update && apt-get install -y curl vim net-tools git iputils-ping wget RUN apt-get install -y python RUN apt-get update && apt-get install -y gcc g++ make libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash ENV NVM_DIR /root/.nvm RUN . $NVM_DIR/nvm.sh && nvm install 7.9.0 && npm install -g [email protected] ADD ./Docker/launch.sh /workspace/ CMD ["/bin/sh", "/workspace/launch.sh"]
The content of
#!/bin/bash cd /workspace/demo npm install node index.js
when I run the docker container:
docker run IMAGE_NAME, I got this error:
npm: not found node: not found
node in this image is managed by
nvm which has been installed and its script has been set on
/root/.bashrc file. But I don’t know why it can’t find the nodejs commands. But if I run the container by
docker run -it IMAGE_NAME bash, then manually run
workspace/launch.sh command, everything works fine. It seems the
~/.bashrc is not executed when run the image. How can I let the container source .bashrc?