Skip to content

Instantly share code, notes, and snippets.

@joshuaaguilar20
Created January 28, 2019 23:55
Show Gist options
  • Save joshuaaguilar20/4c70cc47401578232cd3117d857e6fed to your computer and use it in GitHub Desktop.
Save joshuaaguilar20/4c70cc47401578232cd3117d857e6fed to your computer and use it in GitHub Desktop.
Docker Building Basic Node Application
Building and Running Docker Images
Needs Base Image
Dependencies
Start-Up Command
Touch Dockerfile (no file ext)
inside of file with no ext. define system and variables
# use an existing Image as base
FROM alpine
# download and install dep
RUN apk add --update redis
#the the image what to do
CMD ["redis-server"]
Then Go to Terminal and run docker build . (. meaning all files in folder)
Will output ID of Build
Then Docker Run (ID)
instead of using ID everytime you can use convention to make custom file name
-t yourDockerID/RepoName:version
ex. joshuaaguilar20/DockerClass:1.0 . (last dot for all files)
//builds repo
sudo docker build -t joshuaaguilar20/redisrepo:1.0 .
//runs repo
sudo docker run joshuaaguilar20/redisrepo:1.0
Basic Node DockerFile
# use an existing Image as base Alpine means stripped down version
FROM node:-alpine
# download and install dep
COPY ./ ./
RUN npm install
#the the image what to do
CMD ["npm", "start"]
./ takes current working directory and copies it to current working dir of container
Build File Docker run build . (optional Name)
docker run (filename or ID)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment