I'm trying to create a Docker container running node.js on Amazon Linux to allow native node modules to compile on machine in a suitable form for AWS Lambda.
I'm primarily following this tutorial on The Polyglot Developer, but have also tried one on the AWS Blogs. I am attempting to build the container with the following command in the Dockerfile's parent directory.
docker build -t amazonlinux-node8 .
Steps 1 & 2 complete succesfully but on step 3 throws the following error.
/root/.nvm/nvm.sh: ... tar: command not found
It then exits with the following message.
The command '/bin/sh -c /bin/bash -c "source /root/.nvm/nvm.sh; nvm install 8.10.0"' returned a non-zero code: 1
What changes do I need to make to fix this error?
Dockerfile
FROM amazonlinux:latest
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
RUN /bin/bash -c "source /root/.nvm/nvm.sh; nvm install 8.10.0"
CMD /bin/bash -c "source /root/.nvm/nvm.sh; nvm use 8.10.0"
I have tried the solution suggested on this SO post by adding steps to download tar.x86_64
but this fails and will not install on the amazonlinux
image. I have seen another suggested solution on this post, however it specifically relates to use of the COPY
command in the Dockerfile which is not applicable to my file.