Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install oh-my-zsh in Docker
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "zsh"]
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
# docker exec -it my-app-container /bin/zsh
@b232wang

This comment has been minimized.

Copy link

b232wang commented May 3, 2018

Hi, when I run docker, it's still bash shell, I need to enter zsh switch bash to zsh(oh-my-zsh). I added RUN chsh -s /usr/bin/zsh still not working. Any idea for that? Thanks.

@iamwrm

This comment has been minimized.

Copy link

iamwrm commented May 22, 2018

@b232wang either you make the linux default sh into zsh, or you use docker run -it imageName /bin/zsh

@yurumi

This comment has been minimized.

Copy link

yurumi commented Aug 30, 2018

@232wang Adding CMD ["zsh"] at the end of Dockerfile worked for me.

@rishispeets

This comment has been minimized.

Copy link

rishispeets commented Nov 11, 2018

Good stuff! Couldn't figure out how to get it working. Thanks!

@drew-neely

This comment has been minimized.

Copy link

drew-neely commented Nov 19, 2018

Any idea how to set a zsh theme in a docker container?

@eric-wilson

This comment has been minimized.

Copy link

eric-wilson commented Feb 10, 2019

you can set it before you do the installation.

# the user we're applying this too (otherwise it most likely install for root)
  USER $USER_NAME
  # terminal colors with xterm
  ENV TERM xterm
  # set the zsh theme 
  ENV ZSH_THEME agnoster

  # run the installation script  
  RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
@eric-wilson

This comment has been minimized.

Copy link

eric-wilson commented Feb 10, 2019

The full script would look something like this:

FROM ubuntu:latest

ARG USER_NAME="dockerdude"
ARG USER_PASSWORD="p@$$w0d"

ENV USER_NAME $USER_NAME
ENV USER_PASSWORD $USER_PASSWORD
ENV CONTAINER_IMAGE_VER=v1.0.0

RUN echo $USER_NAME
RUN echo $USER_PASSWORD
RUN echo $CONTAINER_IMAGE_VER

# install the tooks i wish to use
RUN apt-get update && \
  apt-get install -y sudo \
  curl \
  git-core \
  gnupg \
  linuxbrew-wrapper \
  locales \
  nodejs \
  zsh \
  wget \
  nano \
  npm \
  fonts-powerline \
  # set up locale
  && locale-gen en_US.UTF-8 \
  # add a user (--disabled-password: the user won't be able to use the account until the password is set)
  && adduser --quiet --disabled-password --shell /bin/zsh --home /home/$USER_NAME --gecos "User" $USER_NAME \
  # update the password
  && echo "${USER_NAME}:${USER_PASSWORD}" | chpasswd && usermod -aG sudo $USER_NAME

  
  # the user we're applying this too (otherwise it most likely install for root)
  USER $USER_NAME
  # terminal colors with xterm
  ENV TERM xterm
  # set the zsh theme
  ENV ZSH_THEME agnoster

  # run the installation script  
  RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true

  # start zsh
  CMD [ "zsh" ]


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.