[英]Trying to get docker to run, constantly gives me an error
我正在尝试使用docker-compose up
运行docker,但是我继续收到此错误。
Removing storemagento_nginx_1
storemagento_redis_1 is up-to-date
storemagento_db_1 is up-to-date
storemagento_fpm_1 is up-to-date
Recreating f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_storemagento_nginx_1 ...
Recreating f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_storemagento_nginx_1 ... error
ERROR: for f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_f751fff8304c_storemagento_nginx_1 Cannot start service nginx: driver failed programming external connectivity on endpoint storemagento_nginx_1 (7b1963dbb7e3b5ea97394dce65168d4a591301fb834c489aad52a9c2ea4e6eb7): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE)
ERROR: for nginx Cannot start service nginx: driver failed programming external connectivity on endpoint storemagento_nginx_1 (7b1963dbb7e3b5ea97394dce65168d4a591301fb834c489aad52a9c2ea4e6eb7): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE)
ERROR: Encountered errors while bringing up the project.
过去可以正常工作,但是后来我通过brew安装了apache的更新版本,现在每次来回切换时都会发生这种情况。 我曾经能够尝试杀死所有的apache进程或重新启动,但这似乎可行。 但是,现在我无法释放80端口。 如果我杀死了在端口80上运行的所有进程,apache将消失一分钟,然后再次返回。
所以当我跑步
sudo lsof -i :80 | grep LISTEN
httpd 27987 root 4u IPv6 0xcfcc888f0ccae989 0t0 TCP *:http (LISTEN)
httpd 27992 _www 4u IPv6 0xcfcc888f0ccae989 0t0 TCP *:http (LISTEN)
这些过程继续返回。 我试图创建一个别名,可以用来如下正确地杀死进程。 但是我无法在终端上正常工作。
alias stopall-port80="sudo kill -9 $(sudo lsof -i :80 | grep LISTEN | egrep -v 'PID' | awk '{print $2}' | sort -n | uniq)"
如果我只看sudo lsof -i :80 | grep LISTEN | egrep -v 'PID' | awk '{print $2}' | sort -n | uniq
sudo lsof -i :80 | grep LISTEN | egrep -v 'PID' | awk '{print $2}' | sort -n | uniq
sudo lsof -i :80 | grep LISTEN | egrep -v 'PID' | awk '{print $2}' | sort -n | uniq
并将其放在终端中,它将按预期生成正确的PID。 但是,当我尝试运行别名stopall-port80
我得到bash: 27057: command not found
。
UPDATE
这正在工作,而不是使用别名
stopall_port80() {
sudo kill -9 $(sudo lsof -i :80 | grep LISTEN | egrep -v 'PID' | awk '{print $2}' | sort -n | uniq);
}
如果端口释放了“一分钟”,然后又重新使用,则应告知正在启动冲突过程的过程监控系统停止运行该过程 。 如果是MacOS上的Apache httpd,则如下所示:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
由于使用双引号,您的原始代码是在定义别名时而不是在执行别名时构建httpd进程的列表。 您可以通过更改引号类型来解决此问题,但是更好的答案是使用一个函数:
stopall_port80() { sudo kill $(...); }
...它将在函数运行时评估$(...)
,而不是在.bashrc
设置函数时进行评估。
sudo lsof -n -iTCP:80 | awk '/LISTEN/ { print $2 }'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.