Code Monkey home page Code Monkey logo

c0883191_classassignment_3's Introduction

Creating Docker Image from Node + Express Application

Create Dockerfile in the project and copy the following code in the file

# syntax=docker/dockerfile:1
FROM node:18-alpine
LABEL maintainer "[email protected]"
LABEL build_date "2024-02-06"
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 3000
CMD ["node", "app.js"]

Create Docker Image using following command

docker build --tag c0883191-node-assignment3 .
docker images

Run the created Image using below commands

docker run --detach --publish 3000:3000 c0883191-node-assignment3:latest
docker run --detach --publish 3001:3000 c0883191-node-assignment3:latest
docker ps

Stop container using below commands

docker stop determined_proskuriakova
docker stop pensive_antonelli
docker ps
docker ps -a

Remove existing continers using below commands

docker rm 2b85acbe2eca
docker rm 98f12c58ce44
docker ps -a

Run the continers using environment variables

docker run --detach --publish 3000:80 -e PORT=80 c0883191-node-assignment3:latest
docker run --detach --publish 3000:80 -e PORT=80 -e NAME=C1 c0883191-node-assignment3:latest
docker run --detach --publish 3001:8080 -e PORT=8080 -e NAME=C1 c0883191-node-assignment3:latest

Run the continers using environment variables using file

docker run --detach --publish 3000:3000 --env-file my-env.txt c0883191-node-assignment3:latest

Tag your recently created image to publish on DockerHub registry

docker image tag c0883191-node-assignment3:latest sarthak99106/c0883191-node-assignment3:1.0.0
docker images
docker login
docker push sarthak99106/c0883191-node-assignment3:1.0.0

Pull and run the recently pushed image on local docker environment

docker pull sarthak99106/c0883191-node-assignment3:1.0.0
docker run -d -p 3000:3000 sarthak99106/c0883191-node-assignment3:1.0.0

c0883191_classassignment_3's People

Contributors

sarth99016 avatar

Stargazers

Reuben Nellissery avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.