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
Table of contents The first The second Native Js ...
This article mainly introduces how to specify par...
This article mainly introduces how to implement a...
When installing mha4mysql, the steps are roughly:...
Table of contents General upload component develo...
<button> tag <br />Definition and usag...
Generally speaking, after the container is starte...
Preface Previously, I talked about the problem of...
1. First look at the request configuration file, ...
Table of contents Overview What are callbacks or ...
1. Introduction to yum Yum (full name Yellow dogU...
Preface I have always wanted to know how a SQL st...
This article tests the environment: CentOS 7 64-b...
I have summarized 3 methods to deploy multiple fr...
This article example shares the specific code of ...