Michael Durrant
Michael Durrant

Reputation: 96484

Where should I place my bash setup files when using docker?

My Dockerfile is below. Currently I copy the dotfiles (which are referenced within the .bashrc) to /root Is there a better way to organize them?

FROM alpine:latest
LABEL maintainer="Michael Durrant<[email protected]>"
RUN apk add bash git vim
COPY alpine_bashrc /root/.bashrc
COPY .bash_functions.sh /root
COPY .bash_aliases /root
COPY .git-completion.bash /root
RUN "/bin/bash"

Upvotes: 1

Views: 96

Answers (1)

ddavison
ddavison

Reputation: 29032

Instead of having 1 COPY directive for each file, it might be advisable to have a directory instead. The limitation would be that the files must be named as they would appear in the container.

$ ls .
    Dockerfile
    dotfiles/
      .bashrc
      .git-completion.bash
      .bash_functions.sh
      .bash_aliases.sh

Dockerfile

...
COPY dotfiles/ root/

Each of those COPY directives creates a new layer in your container. Save space/time by having one directive.

Upvotes: 3

Related Questions