Add Zsh and OhMyZsh to your setup docker instances

When I first start an application that I know will use docker, I like to avoid having to install ANY dependency that project has. Docker is great for this, because I can create a linked setup / staging environment.

But, I’m also not really willing to give up some of the things I’ve done to make my terminal experience better. For this, I use OhMyZsh

Dockerfile
# Staging Container
FROM node:8.12.0

# Set working directory
RUN mkdir /usr/src/app
WORKDIR /usr/src/app

# Add app
COPY . /usr/src/app

# Install Zsh to make life easier
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

# Add any global dependencies you need
# RUN npm install -g @angular/cli

CMD ["zsh"]

Once you have this Dockerfile in your application directory, you will need to build the image.

Bash
docker build . -t staging

The -t param lets you alias your staging image. In this case, we have given it the alias “staging”.

And finally, to get into the staging image and start your zsh journey…

Bash
docker run --rm -it staging -v "$PWD":/usr/src/app

Leave a Reply

I’m David

Welcome to my little corner of the internet that I dedicate to programming. I’m a principal software engineer at Fynix Consulting and strive to always be learning new things. I love to code and I love to write about coding!

Let’s connect

Discover more from David Boothe's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading