21 iunie 2024

Dockerfile

# specify base image to start from
FROM node:9.4.0-alpine
# copy files
COPY app.js .
COPY package.json .
# execute commands
RUN npm install &&\
    apk update &&\
    apk upgrade
# exposes port 8080 with a specified protocol inside a Docker Container
EXPOSE  8080
# run app.js with executable "node"
CMD node app.js

# Build in the current dir with tag myimage version v1
# > docker build . -t myimage:v1
# > docker images

# Run the image as a container
# -d=detach, run in background
# -p=publish a container's port to the host
# > docker run -dp 8080:8080 myimage:v1

# Ping the application
# > curl localhost:8080

Niciun comentariu: