Hello, I am qui! Today, we'll serve a static page with Docker.
Installing Docker
Install it with your package manager.
Debian/Ubuntu/Mint: https://docs.docker.com/engine/install/debian/#install-using-the-repository
Arch: sudo pacman -S docker docker-compose
Creating Dockerfile
Create Dockerfile. And enter to it.
We'll use nginx image. Add this: FROM nginx:alpine
We want to copy static site to /usr/share/nginx/html in container. Add this: COPY . /usr/share/nginx/html
Complete Dockerfile
FROM nginx:alpine
COPY . /usr/share/nginx/html
Building Container
docker build -t <sitename>:latest .
Run Container
If you want to run site in background, run this command: docker run -d -p 80:80 <sitename>:latest
If you don't want to run site in background, run this command: docker run -p 80:80 <sitename>:latest
If you are getting port errors, change 80:80 with 8080:80.
Top comments (1)
thanks :D