Assuming that you have docker installed and image Alpine is pulled.
Here we only use ngnix:alpine version
Firstly, you can make a simple static html file as you like
Mapping the html file to ngnix docker. Here all docker commands, I'm running as a root user. If you don't enter root mode, in linux you will have to add 'sudo' at the beginning of all commands
The demoweb folder must contain an index.html (do not rename the file to sth like demoweb.html) because it will cause 403 error
docker run --name demoweb -v /home/linh/Desktop/demoweb:/usr/share/nginx/html:ro -d -p 80:8 nginx:alpine
# if :80 port is already in use -> change the port to another one, e.g. 8080:80
Check all calls to the web
docker logs demoweb
# Enter demoweb folder in alpine
docker exec -it demoweb /bin/sh
# top to see processes are running
/ # top
Rather than top, we can use Htop which is an interactive processes viewer
/ # apk update
/ # apk add htop
# after installing htop, runnring htop might run into error: Error opening terminal: unknown.
# probably in linux mint environment, you have to set TERM environment
/ # export TERM=xterm
/ # htop
We can also run benchmark on this process of serving the static web with apache. Open another terminal and run
ab -n 5000 -c 10 http://127.0.0.1:80/
# here we runs 5000 requests with 10 concurrences # change :80 to whatever port you are using
# if apache is not installed, install apache2-utils
sudo apt-get install apache2-utils
- CREATE A DOCKER IMAGE WITH DOCKERFILE
A docker image of a node express file. In the node app folder, add dockerfile
FROM node:7.7.4-alpine
# Create app directory
RUN mkdir -p /usr/src/express
WORKDIR /usr/src/express
COPY . /usr/src/express
EXPOSE 8080
RUN npm install
CMD ["node", "index.js"]
Run docker command:
docker build -t minhcuong/express .
# see images in docker
docker images
# create a container of the image
docker run --name express -p 8080:8080 -d minhcuong/express