Skip to content

Instantly share code, notes, and snippets.

View pablocattaneo's full-sized avatar

Pablo Cattaneo pablocattaneo

View GitHub Profile
# you must to bind a volume suing -v options and run the command at the end of docjer run command
docker run -v $(pwd):/app -p 8000:8000 4116b404dad9 yarn upgrade
# https://docs.docker.com/engine/reference/commandline/start/
docker start [container_name]
The first one is the host port, it means the one that you are going to use to access for example: http://localhost:4000/ the other one is the one set on dockerfile
docker run -d -p 4000:8000 --rm 4116b404dad9
# using -d option
docker run -d -p 8000:8000 4116b404dad9
# create a file and name it Dockerfile
FROM node:lts #baseimage
WORKDIR /app #The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile.
COPY . /app #The COPY instruction copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.
RUN yarn global add gatsby-cli #The RUN instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile.
RUN yarn install
# Only images that are not used for containers can be deleted no matter is the container is running or not.
docker rmi [image_id]