Sed在构buildDocker镜像时找不到文件

我正在尝试构build我的第一个Docker镜像。 我的形象是基于centos:7 。 但是,Docker映像卡住了这个命令:

 RUN /usr/bin/sed -e 's/127.0.0.1:9000/9000/' \       -e '/allowed_clients/d' \       -e '/catch_workers_output/s/^;//' \       -e '/error_log/d' \       -i /etc/php-fpm.d/www.conf 

这是我在build立图像时所得到的:

 Step 5 : RUN /usr/bin/sed -e 's/127.0.0.1:9000/9000/' ??????? -e '/allowed_clien ts/d' ??????? -e '/catch_workers_output/s/^;//' ??????? -e '/error_log/d' ?????? ? -i /etc/php-fpm.d/www.conf ---> Running in 660063647d37 /usr/bin/sed: can't read ???????: No such file or directory /usr/bin/sed: can't read ???????: No such file or directory /usr/bin/sed: can't read ???????: No such file or directory /usr/bin/sed: can't read ???????: No such file or directory INFO[0000] The command [/bin/sh -c /usr/bin/sed -e 's/127.0.0.1:9000/9000/' ???? ??? -e '/allowed_clients/d' ??????? -e '/catch_workers_output/s/^;//' ??????? -e '/error_log/d' ??????? -i /etc/php-fpm.d/www.conf] returned a non-zero code: 2 

但是,当我连接到半build的图像,文件确实在那里:

 vagrant@vagrant-ubuntu-trusty-64:/vagrant/docker$ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE <none> <none> c34b6e6456bd 2 hours ago 295.7 MB centos 7 2b8d6139a545 2 days ago 212.1 MB centos centos7 2b8d6139a545 2 days ago 212.1 MB centos latest 2b8d6139a545 2 days ago 212.1 MB vagrant@vagrant-ubuntu-trusty-64:/vagrant/docker$ docker run -it --rm c34b6e645 6bd [root@b61b0154b97b /]# ls /etc/php-fpm. php-fpm.conf php-fpm.d/ [root@b61b0154b97b /]# ls /etc/php-fpm.d www.conf 

我也证实了sed位于/usr/bin/sed 。 事实上,我已经将这个命令粘贴到了我的会话中,并已经看到了它的工作。

我在这里做错了什么?

如果我在主机上运行sed命令,我也会得到同样的结果。 看起来你的命令在换行方面是畸形的。

我会删除所有的斜杠和新行,并检查它的作品。 然后把它们一次一个地加回去,而不是剪切和粘贴。

错误信息误导了我。 我意识到,当复制和粘贴时, tab符没有被正确粘贴。

我用spacereplace了这些angular色,问题就解决了。