容器映射的端口异常
在防火墙,安全组都开放的情况,依然无法访问容器映射的端口
- 排查出docker启动后修改防火墙等规则,无法生效, 重启docker服务后问题解决.
- systemctl daemon-reload&&systemctl restart docker
容器运行一段时间后莫名停止
a. 该脚本执行完得到输出最高的40个进程, 内存不足时得分最高的会被直接杀死#!/bin/bashfor proc in $(find /proc -maxdepth 1 -regex '/proc/[0-9]+'); doprintf "%2d %5d %s\n""$(cat $proc/oom_score)""$(basename $proc)""$(cat $proc/cmdline | tr '\0' ' ' | head -c 50)"done 2>/dev/null | sort -nr | head -n 40
b. 配置swap 可以缓解
适当调整容器的可用内存, 和容器内应用的内存大小docker镜像没有ifconfig、ping指令
os: Ubuntu / debian
apt-get update #更新源
apt install net-tools # ifconfig
apt install iputils-ping # ping
apt install vim # vim容器访问宿主机 localhost
一般安装docker后 会出现一个 docker0 网卡,可以在容器中访问并指向主机 通常是 172.17.0.1 我的mysql容器中是 172.18.0.1
而在容器中可以通过 ifconfig 查看 etho 找到 一个 _._.*.2 的ip 宿主机通过这个ip 可以访问宿主机时区问题
复制 /usr/share/zoneinfo/Asia/Shanghai 替换后容器中的 /etc/localtime
或者启动时 指定 env
docker system df
- docker system prune -a
- 在 /var/lib/docker/ 下 找到占用空间的 -json.log
a. truncate -s 0 -json.log 清空日志文件
b. docker-compose 指定日志上限
logging:
driver:’json-file’
options:
max-size:’1g’docker运行spring boot 包镜像出现no main manifest attribute问题
<build> <finalName>app</finalName> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <!--docker运行spring boot 包镜像出现no main manifest attribute问题--> <!--项目基于maven pom多模块的开发的,需要设置goal-repackage属性为true,否则打包后文件依赖文件没有一起打包,然后镜像内没有可以运行的程序文件 需要加入下面两项配置--> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> </plugins> </build>
docker 中无法执行 jinfo 等命令
cap_add:
- SYS_PTRACE
