Docker Installation and commands

Docker installation

Remove Docker Initially

sudo apt-get remove docker docker-engine containerd runc

sudo apt update


sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \

FROM node:8

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci — only=production

# Bundle app source
COPY . .

CMD [ “node”, “index.js” ]

Docker Commands

docker build -t image_name .
service docker start
docker images
docker ps
docker run -p 8081:8081 image-id
docker login
docker tag image_tag_name path_of_docker:image_name
docker push path_of_image
docker pull path_of_image:image_name
docker run -p 8081:8081 image_tag_name
docker run -p 3000:3000 -it image_path:image_name