Home  >  Q&A  >  body text

docker exec 报错,怎么回事?

admin@ubuntu:/mnt/data/web$ sudo docker exec web-server -i -t /bin/bash
rpc error: code = 13 desc = invalid header field value "oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"-i\\\": executable file not found in $PATH\"\n"

顺便,我还有个问题,我的dockerfile文件内容如下

FROM ubuntu:latest
RUN apt-get -qq update
RUN apt-get install -qqy nginx php-fpm php-mcrypt
RUN rm -rf /var/lib/apt/lists/*
EXPOSE 80 443
CMD ["/etc/init.d/nginx", "start"]                               

我build好之后,运行之后容器会退出,然后我start:

admin@ubuntu:/mnt/data/web$ sudo docker start -a -i web-server
cat: /etc/nginx/nginx.conf: No such file or directory
 * Starting nginx nginx
   ...fail!

就这样。这是怎么回事?
我run的命令如下:

sudo docker run --name web-server --link db-mysql:mysql -v /mnt/data/web/htdocs -v /mnt/data/web/nginx.conf.d:/etc/nginx -p 80:80 -p 443:443 -d nginx-php:latest

我都在公司在虚拟机里面都试过了一边,回家跑到我的vps上去搞,就是搞不成,气死我。。。。。

过去多啦不再A梦过去多啦不再A梦2756 days ago1136

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-26 09:04:13

    1. Docker exec reports an error because the /bin/bash file does not exist. You can try /bin/sh etc.

    2. Check whether there is an nginx.conf file in the /mnt/data/web/nginx.conf.d directory of the host machine.

    3. The use of docker does not follow best practices. For configuration of web server, please refer to Docker Practice (8): Building Laravel Development Environment.

    4. Please read carefully the Snail Under the Bridge - Docker Q&A (93 questions) before learning docker.

    reply
    0
  • 阿神

    阿神2017-04-26 09:04:13

    docker exec -it web-server bash
    It is recommended not to put the two services nginx and PHP-fpm in the same container
    You can refer to this docker to deploy nginx and php-fpm

    reply
    0
  • Cancelreply