参考链接:https://bibichuan.github.io/posts/751a51b1.html

软件更新缓存问题:

需要注意一个关于软件源更新安装软件的问题。
如果我们需要更新软件源并安装软件源中的软件vim,在Linux环境中我们一般会执行这个的命令:

  1. apt update
  2. apt install -y vim

如果需要在镜像中安装软件,我们会想当然地在 Dockerfile 写成这样

  1. RUN apt update
  2. RUN apt install -y vim

Dockerfile 构建一次之后,apt update 构建的镜像层就会缓存到本地,无论后面这个 Dockerfile 如何更新 apt install 的内容,apt update 镜像缓存也不会更新,这会导致安装的始终是第一次 Dockerfile构建时获取的软件源版本,除非你手动删除这些缓存镜像层。
解决的方法:用 RUN apt-get update && apt-get install -y 可以确保 Dockerfiles 每次安装的都是包的最新的版本。

nginx访问PHP报file not find upstream
定位:nginx与PHP安装时挂载的代码目录不一致导致:

  1. docker run \
  2. -d \
  3. -p 9000:9000 \
  4. -v D:/code/php/soterea:/usr/share/nginx/html \
  5. --link mysql:mysql \
  6. --name php php:7.3-fpm
  7. docker run \
  8. -d \
  9. -p 80:80 \
  10. -v D:/code/php/soterea:/usr/share/nginx/html \
  11. -v D:/container/nginx/conf.d:/etc/nginx/conf.d \
  12. --link php:php \
  13. --name nginx nginx
  1. root@c4ac82529301:/# apt-get update
  2. Err:1 http://security.debian.org/debian-security buster/updates InRelease
  3. Temporary failure resolving 'security.debian.org'
  4. Err:2 http://repo.mysql.com/apt/debian buster InRelease
  5. Temporary failure resolving 'repo.mysql.com'
  6. Err:3 http://deb.debian.org/debian buster InRelease
  7. Temporary failure resolving 'deb.debian.org'
  8. Err:4 http://deb.debian.org/debian buster-updates InRelease
  9. Temporary failure resolving 'deb.debian.org'
  10. # 原因
  11. # 出现此问题,一般是因为DNS设置的问题,将DNS设置为 8.8.8.8
  12. #通过下面命令查看DNS
  13. cat /etc/resolv.conf
  14. # 通过下面命令修改DNS
  15. echo "nameserver 8.8.8.8" | tee /etc/resolv.conf > /dev/null
  16. cat /etc/resolv.conf
  17. nameserver 8.8.8.8