参考链接:https://bibichuan.github.io/posts/751a51b1.html
软件更新缓存问题:
需要注意一个关于软件源更新安装软件的问题。
如果我们需要更新软件源并安装软件源中的软件vim,在Linux环境中我们一般会执行这个的命令:
apt updateapt install -y vim
如果需要在镜像中安装软件,我们会想当然地在 Dockerfile 写成这样
RUN apt updateRUN 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安装时挂载的代码目录不一致导致:
docker run \-d \-p 9000:9000 \-v D:/code/php/soterea:/usr/share/nginx/html \--link mysql:mysql \--name php php:7.3-fpmdocker run \-d \-p 80:80 \-v D:/code/php/soterea:/usr/share/nginx/html \-v D:/container/nginx/conf.d:/etc/nginx/conf.d \--link php:php \--name nginx nginx
root@c4ac82529301:/# apt-get updateErr:1 http://security.debian.org/debian-security buster/updates InReleaseTemporary failure resolving 'security.debian.org'Err:2 http://repo.mysql.com/apt/debian buster InReleaseTemporary failure resolving 'repo.mysql.com'Err:3 http://deb.debian.org/debian buster InReleaseTemporary failure resolving 'deb.debian.org'Err:4 http://deb.debian.org/debian buster-updates InReleaseTemporary failure resolving 'deb.debian.org'# 原因# 出现此问题,一般是因为DNS设置的问题,将DNS设置为 8.8.8.8#通过下面命令查看DNScat /etc/resolv.conf# 通过下面命令修改DNSecho "nameserver 8.8.8.8" | tee /etc/resolv.conf > /dev/nullcat /etc/resolv.confnameserver 8.8.8.8
