REFERENCE
Custom dockerfile reference for TypeScript Node Express API Service Starter
IMAGE
Build
Build Docker Image from dockerfile
docker build --tag <image-name> .
docker build -t <image-name> .
Build Docker Image from Dockerfile with alt file name
docker build --file ./path/to/dockerfile --tag <image-name> .
Example
docker build --file Dockerfile.development --tag ts-express/zoho-api-service
CONTAINER
Create Container
docker create --name <container-name> --port <external-prot>:<internal-port> <image-name>
docker create --name <container-name> <image-name>
Example
docker create --name ts-express-zoho-api-service-1 ts-express/zoho-api-service
Start Container
docker start -i <container-name>
Example
docker start -i ts-express-zoho-api-service-1
Run Container
Docker Run is a combination of create
and start
docker run --name <container-name> -it -p 3333:3333 <image-name>
Example
docker run --name -it ts-express-zoho-api-service-1 -p 3333:3333 ts-express/zoho-api-service
Hot Reload Watch
docker run --name <container-name> -v $PWD:/app -v app/node_modules -p 3333:3333 <image-name>
Execute Command in Container
docker exec -it <container-name> bash
or
docker exec -it <container-name> sh
example
docker exec -it l-dev bash
docker exec -it <container-name> sh