分类 "Docker" 下的文章

docker启动不起来,查看日志错误内容如下:

$ docker logs -f go-advertise
  1. "no such file or directory"

    $ docker logs -f go-advertise
    standard_init_linux.go:211: exec user process caused "no such file or directory"

    因为我是在Windows环境下,启动脚本是run.sh。打开git bash,设置fileformatunix

    $ vim run/sh
    
    :set ff=unix
  2. 创建不了文件夹

    $ docker logs -f go-advertise
    mkdir: can't create directory '/data/logs/': No such file or directory
    /run.sh: line 3: can't create /data/nginx/log/go-advertise.error.log: nonexistent 
    directory

    入口文件是run.sh,代码如下:

    #!/bin/sh
    mkdir -p /data/logs/golang/
    ./go-advertise start -env=dev >> /data/nginx/log/go-advertise.error.log 2>&1

    我在Dockerfile创建日志目录

    RUN mkdir -p /data/nginx/log && \n
    mkdir -p /data/logs/golang/ && \n
    touch /data/nginx/log/go-advertise.error.log

参考链接:docker启动报错:standard_init_linux.go:211: exec user process caused "no such file or directory"

# 可以是容器的ID,也可以是容器的名称
docker inspect {容器ID}
# 比如查看名称为myphp7.2的container
docker inspect myphp7.2
# "IPAddress": "172.17.0.2"