zoukankan      html  css  js  c++  java
  • Windows环境搞好的Dockerfile文件 在Linux上报错了

    错误1:
    standard_init_linux.go:187: exec user process caused "no such file or directory"

    [root@izbp1dcscvry6tnoiqx8stz manager]# docker run --name managerV1 newhub.zkh360.com/zkh360/otter-manager-uat:v0.1
    standard_init_linux.go:187: exec user process caused "no such file or directory"
    [root@izbp1dcscvry6tnoiqx8stz manager]#
    [root@izbp1dcscvry6tnoiqx8stz manager]# docker logs managerV1
    standard_init_linux.go:187: exec user process caused "no such file or directory"
    [root@izbp1dcscvry6tnoiqx8stz manager]#

    原因: 镜像的entrypoint设置的启动脚本格式是dos,在linux系统上用vi修改成unix格式即可 【windows下操作之伤】
    把.sh文件逐个执行以下操作:

    1)用vi打开文件
    2)执行 :set ff 然后回车,可以看到fileformat=dos

    3)修改成unix
    :set ff=unix 回车
    4)执行:set ff,可以看到已经改为 fileformat=unix
    https://www.wandouip.com/t5i111338/

    错误2:

    [root@izbp1dcscvry6tnoiqx8stz manager]# docker run 793059909/otter-manager-uat:v0.2 -it bash
    DOCKER_DEPLOY_TYPE=VM
    ==> INIT /alidata/init/02init-sshd.sh
    ==> EXIT CODE: 0
    ==> INIT /alidata/init/fix-hosts.py
    /alidata/bin/main.sh: /alidata/init/fix-hosts.py: /usr/bin/python^M: bad interpreter: No such file or directory
    ==> EXIT CODE: 126
    ==> INIT DEFAULT
    Generating SSH1 RSA host key: [  OK  ]
    Starting sshd: [  OK  ]
    Starting crond: [  OK  ]
    ==> INIT DONE
    ==> RUN -it bash
    /alidata/bin/main.sh: line 27: exec: -i: invalid option
    exec: usage: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
    [root@izbp1dcscvry6tnoiqx8stz manager]#

    看了下main.sh的第27行是:

    #!/bin/bash
    
    [ -n "${DOCKER_DEPLOY_TYPE}" ] || DOCKER_DEPLOY_TYPE="VM"
    echo "DOCKER_DEPLOY_TYPE=${DOCKER_DEPLOY_TYPE}"
    
    # run init scripts
    for e in $(ls /alidata/init/*) ; do
        [ -x "${e}" ] || continue
        echo "==> INIT $e"
        $e
        echo "==> EXIT CODE: $?"
    done
    
    echo "==> INIT DEFAULT"
    service sshd start
    service crond start
    
    #echo "check hostname -i: `hostname -i`"
    #hti_num=`hostname -i|awk '{print NF}'`
    #if [ $hti_num -gt 1 ];then
    #    echo "hostname -i result error:`hostname -i`"
    #    exit 120
    #fi
    
    echo "==> INIT DONE"
    echo "==> RUN ${*}"
    exec "${@}"


    先解决Py报错的事,相关也是文件格式的事。果然:

    仔细检查报错内容,并不会发现任何语句错误或者路径错误,注意^m,这是windows下的断元字符。所以问题就是,在多个环境上进行编写,可能会因为字符(win/unix换行符不一样)、缩进(两个编辑环境的缩进tab/space不一致)均易导致这种神不知鬼不觉的错误,很难找到。

    解决方法见上面*.sh脚本的解决办法

    https://blog.csdn.net/qq_31331027/article/details/84590300


    [root@iZbp1ftvuebdvy5eo7i9x5Z canal]# docker run -it newhub.youhuale.cn/youhuale/canal-omssapvcpro:v0.2 bash
    /usr/bin/docker-current: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
    See '/usr/bin/docker-current run --help'.

    [root@iZbp1ftvuebdvy5eo7i9x5Z canal]# systemctl daemon-reload
    [root@iZbp1ftvuebdvy5eo7i9x5Z canal]# systemctl restart docker.service
    [root@iZbp1ftvuebdvy5eo7i9x5Z canal]# docker run -it newhub.youhuale/zkh360/canal-omssapvcpro:v0.2 bash
    Unable to find image 'newhub.youhuale/zkh360/canal-omssapvcpro:v0.2' locally
    Trying to pull repository newhub.youhuale/zkh360/canal-omssapvcpro ...
    /usr/bin/docker-current: repository newhub.youhuale/zkh360/canal-omssapvcpro not found: does not exist or no pull access.
    See '/usr/bin/docker-current run --help'.

    进行docker login

    [root@iZbp1ftvuebdvy5eo7i9x5Z canal]# docker login newhub.youhuale.com
    Username: root
    Password:
    Login Succeeded
    [root@iZbp1ftvuebdvy5eo7i9x5Z canal]#






  • 相关阅读:
    2018年第九届蓝桥杯【C++省赛B组】第二题 明码
    2018年第九届蓝桥杯【C++省赛B组】第三题 乘积尾零
    2018年第九届蓝桥杯【C++省赛B组】第四题 测试次数
    L2-023 图着色问题
    L2-011 玩转二叉树
    获取当前的时间,转化为char[]格式unix时间戳
    创建子进程
    strerror
    gdb
    gcc
  • 原文地址:https://www.cnblogs.com/softidea/p/13368456.html
Copyright © 2011-2022 走看看