Generate an Docker image with Node and Create React App installed. For this edit a file called Dockerfile with the following content:
FROM node:6-alpine
# Install create-react-app
RUN npm install -g create-react-app
WORKDIR /src
CMD [ "node" ]
Build the image with the following command:
$ docker build -t react-app .
Generate a blank app with:
$ mkdir app
$ docker run -it --rm -v "$PWD"/app:/usr/src/app -w /usr/src react-app create-react-app app
To run the app:
$ docker run -it --rm --expose 3000 -v "$PWD"/app:/usr/src/app -w /usr/src/app react-app yarn start
The app will launch. You can access it on whatever IP Docker is running on (usually 172.x.x.x). On my machine I need to connect to:
Since the Docker runs as root you should change ownership of the app/ directory (from there on up) to your user:
$ sudo chown -R `id -u`:`id -g` app
Where [user] and [group]