Docker container is an open source application engine, allows developers to pack their applications and rely on the package to a portable container, the container contains the application code, running environment, rely on libraries, the configuration file, such as the necessary resources, can be achieved by container convenient fast and automated deployment with platform decoupling way, Regardless of the environment in which you deploy, the applications in the container will run in the same environment. As a lightweight virtualization technology, Docker has advantages such as continuous integration, version control, portability, isolation and security.

Nginx is a high-performance HTTP and reverse proxy server. The Nginx image is used as the basis for building vUE application images.

Docker starts

Tools: MobaXterm

The installationDocker

 yum install docker
Copy the code

Start the servicestart docker

systemctl start docker
Copy the code

Pull in the DockernginxThe mirror

docker pull nginx
Copy the code

Creating a Configuration file


  • Custom image building is based onDockerfile To build.
  • FROM nginx:latestThis image is built on the nginx: Latest image.
  • COPY dist/ /usr/share/nginx/html/ The: command copies all files in the dist folder at the root of the project to the image/usr/share/nginx/html/ Directory.
  • COPY default.conf /etc/nginx/conf.d/default.confCommand will mean Nginx directory. The default conf copied to the/etc/Nginx/conf. D/default. Conf, with local default. Conf configuration to replace Nginx default configurations in the mirror.
FROM nginx:latest MAINTAINER [email protected] # MAINTAINER information # COPY all files in the dist folder in the root directory of the project to the /usr/share/nginx/ HTML/directory dist/ /usr/share/nginx/html/ COPY default.conf /etc/nginx/conf.d/default.confCopy the code


Upstream my_server {server; # Back end server address keepalive 2000; } server { listen 80; server_name; # Charset koi8-r; #charset koi8-r; access_log /var/log/nginx/host.access.log main; error_log /var/log/nginx/error.log error; location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.html =404; {proxy_pass http://my_server/api;} {proxy_pass http://my_server/api;} proxy_set_header Host $host:$server_port; rewrite ^/api/(.*) /$1 break; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}Copy the code

Will package the project, putdistFolder and just createdDockerfile.default.confIn the same directory

Build the mirrorbuild images

docker build -t admin .
Copy the code

Look at mirrorimages

docker images

Copy the code

Start the container

docker run -d -p 8136:80 --name dooringx-admin admin
Copy the code
  • -d Running in background mode
  • -p 8136:80 Port mapping: maps port 8136 of the host to port 80 of the container
  • – name Container name Image name

View the running containercontainer

docker ps
Copy the code

Viewing container Logslogs

Check docker logs when the container is abnormalCopy the code

Remove the mirrorrm images

  • Stop running the container and remove itstop && rm
Docker rm < docker ID or docker name > docker stop dooringX-admin // Docker rm < docker ID or docker name > docker rm dooringX-admin // View the current container docker Container ls -aCopy the code

  • Remove the mirrorimage rm
 docker image rm doorxing-admin

Copy the code

Finally, open a browser and enter your server IP/domain name port number :8136

In the future, Docker can be automatically deployed with Github Webhooks and Jenkins as required