Docker启动容器失败查看容器日志

1.docker ps -a 查看容器进程
CONTAINER ID   IMAGE             COMMAND                  CREATED          STATUS                      PORTS     NAMES
c5fe8083e7e6   centos_nginx:v1   "/bin/sh -c '/bin/sh…"   10 seconds ago   Exited (1) 9 seconds ago              web01

2.比如启动nginx失败,要查看日志,容器id是c5fe8083e7e6,或者查看NAMES

用NAMES查看日志位置
docker inspect --format '{{.LogPath}}' web01

用容器id方式查看日志位置
docker inspect --format '{{.LogPath}}' c5fe8083e7e6 

查看对应容器日志
cat /var/lib/docker/containers/5af0b17f2572d6e1d802df364134254cc3e8169e154-json.log

3.报错日志,就能去解决了
{"log":"nginx: [emerg] open() \"/usr/local/nginx/conf/mime.types\" failed (2: No such file or directory) in /usr/local/nginx/conf/nginx.conf:6\n","stream":"stderr","time":"2022-06-28T03:19:45.354109867Z"}

  

posted @ 2022-09-19 21:10  lucky_tomato  阅读(2607)  评论(0编辑  收藏  举报