Skip to content

Instantly share code, notes, and snippets.



Last active Jan 31, 2018
What would you like to do?
Docker and docker-compose setup for a simple node environment which is setup to support using `yarn` and `yo`

Run Yarn and Yeoman in a Docker container

Part of my mission to not install any dev tools or dev environments outside of Docker.

Build container

Run docker-compose build.

Get a bash prompt in the container

Run docker-compose run app bash.

Start a new project with yarn


docker-compose run app bash
yarn init


docker-compose run app yarn init

Adding additonal yeoman generators:

  1. Modify Dockerfile to globally include additional generators

    • example: Add RUN yarn globa add generator-exrpess to the end of the Dockerfile
  2. Run docker-compose build to rebuild the container

  3. Either:

    docker-compose run app bash
    yo express


    docker-compose run app yo express
version: "2"
build: .
working_dir: /home/docker/app
- NODE_ENV=production
- ./:/home/docker/app
FROM node:9.3
RUN apt-get update
RUN apt-get install sudo
RUN adduser --disabled-password --gecos '' docker
RUN adduser docker sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER docker
RUN sudo apt-get update
RUN sudo apt-get install apt-transport-https
RUN sudo curl -sS | sudo apt-key add -
RUN sudo echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
RUN sudo apt-get update
RUN sudo apt-get install yarn
ENV PATH=/home/docker/.yarn/bin:$PATH
RUN yarn global add yo

This comment has been minimized.

Copy link

@joshkel joshkel commented Jan 19, 2018

Nitpick: "Yeoman," not "Yoeman."

(I need to learn Docker. Thanks for the reminder.)


This comment has been minimized.

Copy link
Owner Author

@mscottford mscottford commented Jan 31, 2018

Thanks for pointing that out! I've updated it.

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.