First time using docker to package and deploy images locally First of all, my laptop system is MACOS 10.15.4 1. The project structure is as follows: This is a react project, and the packaged static resource path is the dist directory. 2. Focus Dockerfile and docker/nginx.conf file1. Dockerfile is a text file used to build images. For detailed introduction, please refer to the link: Docker Dockerfile My Dockerfile content is as follows: FROM nginx WORKDIR /usr/src/app/ COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf COPY ./dist /usr/share/nginx/html/ EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] The capitalized words in Dockerfile are commands. The meaning of each command is explained as follows:
2. docker/nginx.conf server { listen 80; # gzip config gzip on; gzip_min_length 1k; gzip_comp_level 9; gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; gzip_vary on; gzip_disable "MSIE [1-6]\."; client_max_body_size 100m; root /usr/share/nginx/html; location / { try_files $uri $uri/ /index.html; } location /api/ { # Here is the backend address proxy_pass http://www.XXX.com/; } } 3. Execute the docker build command to create an image The command I executed is: 4. Execute docker run to deploy the image The command I executed is: 5. Open localhost:80 to see the projectThis is my first experience with Docker local deployment. I am still not very clear about many principles and Docker commands. I will learn more about them in the future. I'd like to add a small problem. Today I suddenly couldn't push the image to the company's private cloud. It was a problem with the network environment, so I asked a colleague to help push it. docker save 10.10.10.52:5000/zhanwu-study/prod:4.1.2 > study.tar Then send the study.tar file generated in the current directory to your colleague via DingTalk. He downloads the study.tar file to his local computer and executes: docker load < study.tar Update the version (no new image is generated, the two versions are the same image): docker tag 10.10.10.52:5000/zhanwu-study/prod:4.1.2 10.10.10.52:5000/zhanwu-study/prod:4.1.3 Then push to the private cloud: docker push 10.10.10.52:5000/zhanwu-study/prod:4.1.3 This is the end of this article about how to use docker to package and deploy images locally. For more relevant local docker packaging and deployment images, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A brief introduction to VUE uni-app core knowledge
>>: XHTML introductory tutorial: text formatting and special characters
This article example shares the specific code of ...
The storage size and range of each floating point...
Table of contents Boot Options Command Line Long ...
Supervisor Introduction Supervisor is a client/se...
This article example shares the specific code of ...
Docker is an open source container engine that he...
Zabbix server environment platform ZABBIX version...
In Linux system, newly install docker and enter t...
Table of contents 1. What is a prototype? 2. Prot...
There are many seemingly true "rumors" ...
Table of contents 1. Location Object 1. URL 2. Pr...
Table of contents What is ReactHook? React curren...
Preface Previously, static IPs assigned using pip...
The following is some basic sql knowledge I have ...
Table of contents Use of CURRENT_TIMESTAMP timest...