- TS application listening port: 7777
|-- dist
|-- src
|-- .dockerignore
|-- Dockerfile
|-- package.json
|-- package-lock.json
`-- tsconfig.json
package.json
scripts
"scripts": {
"build": "tsc",
"start": "node ./dist/main.js"
}
FROM node:10-alpine
# update packages
RUN apk update
# create root application folder
WORKDIR /app
# copy configs to /app folder
COPY package*.json ./
COPY tsconfig.json ./
# copy source code to /app/src folder
COPY src /app/src
# check files list
RUN ls -a
RUN npm install
RUN npm run build
EXPOSE 7777
CMD [ "node", "./dist/main.js" ]
Build docker image
docker build -t test-image-name .
Run image in interactive mode
docker run -it -p 7777:7777 test-image-name
Or run image in silent(daemon) mode
docker run -d -p 7777:7777 test-image-name
List all images
docker image ls
Remove all images at once
docker rmi $(docker images -q)
List all active containers
docker ps
List all active and dead containers
docker ps -a
Stop all running containers
docker stop $(docker ps -a -q)
Delete all stopped containers:
docker rm $(docker ps -a -q)
Install help utils
apt-get install iputils-ping nmap
Jump into container shell
docker exec -it CONTAINER_ID /bin/sh