[英]Trying to get docker to run, constantly gives me an error
I am trying to run docker with docker-compose up
, but I continue to get this 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.
This used to work fine, but then I installed an updated version of apache through brew and now this happens every time I switch back and forth. 过去可以正常工作,但是后来我通过brew安装了apache的更新版本,现在每次来回切换时都会发生这种情况。 I used to be able to try and kill all of the apache processes or restart and that seemed to work. 我曾经能够尝试杀死所有的apache进程或重新启动,但这似乎可行。 However now I can not get port 80 to free up. 但是,现在我无法释放80端口。 If I kill all processes running on port 80 apache will go away for a minute, but then return again. 如果我杀死了在端口80上运行的所有进程,apache将消失一分钟,然后再次返回。
So when I run 所以当我跑步
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)
These processes continue to return. 这些过程继续返回。 I was trying to create an alias that I could use to kill the processes correctly as below. 我试图创建一个别名,可以用来如下正确地杀死进程。 But I can not get this working in terminal. 但是我无法在终端上正常工作。
alias stopall-port80="sudo kill -9 $(sudo lsof -i :80 | grep LISTEN | egrep -v 'PID' | awk '{print $2}' | sort -n | uniq)"
If I take just the section 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
and put it in the terminal it produces the correct PID's as expected. sudo lsof -i :80 | grep LISTEN | egrep -v 'PID' | awk '{print $2}' | sort -n | uniq
并将其放在终端中,它将按预期生成正确的PID。 However when I try to run the alias stopall-port80
I get bash: 27057: command not found
. 但是,当我尝试运行别名stopall-port80
我得到bash: 27057: command not found
。
UPDATE UPDATE
This is working instead of using the alias 这正在工作,而不是使用别名
stopall_port80() {
sudo kill -9 $(sudo lsof -i :80 | grep LISTEN | egrep -v 'PID' | awk '{print $2}' | sort -n | uniq);
}
If the port frees up "for a minute" and then is in use again, you should tell the process supervision system that's starting the conflicting process to stop running that process . 如果端口释放了“一分钟”,然后又重新使用,则应告知正在启动冲突过程的过程监控系统停止运行该过程 。 In the case of Apache httpd on MacOS, that looks like: 如果是MacOS上的Apache httpd,则如下所示:
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Your original code was -- on account of the use of double quotes -- building the list of httpd processes at the time when your alias was defined , not at the time when your alias was executed . 由于使用双引号,您的原始代码是在定义别名时而不是在执行别名时构建httpd进程的列表。 You could fix that by changing the quoting type, but the better answer is to use a function: 您可以通过更改引号类型来解决此问题,但是更好的答案是使用一个函数:
stopall_port80() { sudo kill $(...); }
...which will evaluate the $(...)
when the function is run, not when it's set up in your .bashrc
. ...它将在函数运行时评估$(...)
,而不是在.bashrc
设置函数时进行评估。
sudo lsof -n -iTCP:80 | awk '/LISTEN/ { print $2 }'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.