I tried to copy a local file (a .vimrc file) to a Docker Alpine image.
Alpine's root directory seems to be called ~. (which is kinda odd, since ~ is usually home in the Debian world)
And the init.vim file needs to be in root/~.
I've tried different methods, i.e. the COPY command and RUN cp ....
But the ~/.config/nvim folder remains empty.
(the mkdir commands work)
I was able to copy into home/.config/nvim, but the file does not have an effect in there it needs to be in ~.
Is the root directory read only (even for root user) in Alpine?
FROM alpine
RUN apk add neovim
RUN apk add neovim-doc
RUN mkdir ~/.config
RUN mkdir ~/.config/nvim
ADD init.vim ~/.config/nvim/
CodePudding user response:
in alpine image ~ alias is equal to /root folder
but the symbol is not interprated in Dockerfile
so it will be treated as a string and it will create a subfolder in / call ~
To copy into good folder i advice you using variable $HOMEthat contain your expected value
but by default ADD and COPY don't have access to $HOME Dockerfile: $HOME is not working with ADD/COPY instructions
one way can be to define the HOME variable you want to use
your Dockerfile will look like :
FROM alpine
ENV HOME /root
RUN apk add neovim
RUN apk add neovim-doc
RUN mkdir $HOME/.config
RUN mkdir $HOME/.config/nvim
COPY init.vim $HOME/.config/nvim/
