A
A
Aleksey Vakhrameev2019-12-18 11:09:58
linux
Aleksey Vakhrameev, 2019-12-18 11:09:58

Docker question from a beginner, how to build an image?

I want to build an image from alpine and install bash there by default, Node version manager, and use it to install nodejs v12.13.1, here is the Dockerfile

FROM alpine

RUN apk update

RUN apk add bash

RUN apk add wget

#RUN export SHELL=/bin/bash

RUN cd ~ && touch .bashrc

RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash

SHELL ["/bin/bash", "-c"]

RUN echo $0

RUN nvm install 12.13.1

RUN nvm use 12.13.1

but the build crashes on the line RUN nvm install 12.13.1with the message /bin/bash: nvm: command not found
while commenting out
#RUN nvm install 12.13.1

#RUN nvm use 12.13.1

and go into the container docker run -it imagename bash
then it nvm install 12.13.1works and installs.
But nvm use 12.13.1it crashes with an error
env: can't execute 'node': No such file or directory
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v12.13.1` to unset it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2019-12-18
@vitaly_il1

add
. ~/.nvm/nvm.sh
before
nvm install

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question