Skip to content

Instantly share code, notes, and snippets.

@silvioramalho
Created January 14, 2021 12:07
Show Gist options
  • Save silvioramalho/6670f1838f996cc0943f49a3e66fd3ba to your computer and use it in GitHub Desktop.
Save silvioramalho/6670f1838f996cc0943f49a3e66fd3ba to your computer and use it in GitHub Desktop.
Building a docker image

Building a docker image

Dockerfile sample

FROM node:latest
MAINTAINER Silvio Ramalho

ENV NODE_ENV=production
ENV PORT=3000

COPY . /var/www
WORKDIR /var/www
RUN npm install

ENTRYPOINT [ "npm", "start" ]
EXPOSE $PORT

Build

  • -f file name Dockerfile (can has name as xxxx.dockerfile too)
  • -t image name user/image_name
  • . path to docker file

docker build -f Dockerfile -t silvioramalho/node .

The image is created and made available on the local host.

To show the image list:

docker images

Run container

docker run -d -p 8080:3000 silvioramalho/node

Check if running

docker ps

Send image to Docker Hub

docker login

docker push silvioramalho/node

Download the image

docker pull silvioramalho/node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment