The first step is to write a Dockerfile from which Docker will automatically deploy your project step by step
# Install nginxFROM nginx in container
# remove nginx default. Conf RUN rm/etc/nginx/conf. D/default. Conf
ADD default.conf /etc/nginx/conf.d/ to /etc/nginx/conf.d/
Dist / /usr/share/nginx/ HTML/COPY dist/ /usr/share/nginx/ HTML /
Copy the code
Having Dockerfile files and front-end projects in one folder makes packaging easier, as shown in the figure
(In fact, at this point in project development, you can directly deploy the project to operations)
You can then test it locally as well as on a server deployment
Run under the current file and press Enter to generate an image named test_web88
Docker build-t test_web88. // Remember to add a space and a dotCopy the code
To view the generated image, run the following command
docker images
Copy the code
Here is our generated image, named test_web88
Run the image as follows
docker run -d -p 8686:8686 aa43e674b9f8
// -d// -p is the port opened by the mapping port container: server port (originally mapped to port 80, some of my previous projects were occupied) // The string behind is the ID of the mirror (like the image information).Copy the code
Enter the command enter
To check whether the image is running successfully, run the following command
docker psCopy the code
The image is running, go to port 8686 in your browser, try it (this IP address is assigned by my Docker)