gourd 2022-06-24 07:10:29 阅读数:650
View the existing image version
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE link v12 baa606cdbecb About an hour ago 78.4MB link v11 eadbb1c71db6 5 weeks ago 78.4MB
Enter the image modification file
$ docker run --name link -d -p 80:80 link:v12 30f0e4c4545934e9b62b9c282b482232635f4e23854a55350b6d0071d004cfed $ docker exec -it 30f0e4c45459 sh / # sed -i 's/wang/zi.wang/g' /etc/nginx/conf.d/default.conf / # cat /etc/nginx/conf.d/default.conf server { listen 80; server_name localhost; location / { root /usr/src/app/; index index.html index.htm; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript; gzip on; if_modified_since off; etag off; add_header Last-Modified "zi.wang"; if (!-e $request_filename) { rewrite ^/[^.]+$ /index.html break; } } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } / # exit
Submit mirrored version
$ docker commit -m='add header' -a='wangzi' 30f0e4c45459 link:v13 sha256:60752f362f4e8f856e94133ce2d56393fa9834eb53c2b94b74f6f654f7863cfb $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE link v13 60752f362f4e 5 seconds ago 78.4MB link v12 baa606cdbecb About an hour ago 78.4MB link v11 eadbb1c71db6 5 weeks ago 78.4MB
Run the image and verify it
$ docker run -d -p 8080:80 link:v13 a6c5e1f7cca9d93cc68b7cfefe24fed0ad981f14ae78aeb36c66c79a17ca2d92 $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a6c5e1f7cca9 link:v13 "/docker-entrypoint.…" 3 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp tender_goodall $curl -i 127.0.0.1:8080 HTTP/1.1 200 OK Server: nginx/1.21.0 Date: Sat, 03 Jul 2021 11:51:58 GMT Content-Type: text/html Content-Length: 514 Connection: keep-alive Last-Modified: zi.wang Accept-Ranges: bytes
Finally, you can see that the Last-Modified property of Response Haader has been modified in the new version.
Create Dockerfile
Dockerfile
FROM nginx:mainline-alpine-perl COPY ./nginx.conf /etc/nginx/conf.d/default.conf ADD ./dist/ /usr/src/app/ # Define default command. CMD ["nginx", "-g", "daemon off;"] # Expose ports. EXPOSE 80
Create the build&run script
build_run.sh
#!/bin/bash npm run build docker build -t link:$1 . docker run --name link -d -p 80:80 link:$1
Run the build&run script
build command
bash build_run.sh v11
Check that the image repository has generated a new version of the image
check
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE link v11 eadbb1c71db6 5 $ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5cba6642ce99 link:v11 "/docker-entrypoint.…" About a minute ago Exited (127) About a minute ago angry_carver
Operation and maintenance log of hoist - Wang Zi's personal blog
copyright:author[gourd],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/175/20210703223947572E.html