php 启动用户空间代理时出错:listen tcp0.0.0.0:3306: bind: address already in use

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37896369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 01:25:39  来源:igfitidea点击:

Error starting userland proxy: listen tcp0.0.0.0:3306: bind: address already in use

phpapachedockerlaravel-5docker-compose

提问by moonlight

ERROR:for dockervel_mysql_1 Cannot restart containerc258b418c03cbd6ec02c349c12cf09403f0eaf42fa9248019af7860d037d6474: driver failed programming external connectivity on endpoint dockervel_mysql_1(da3dd576458aa1fe3af7b539c48b9d61d97432cf5e9ee02d78562851f53981ae): Error starting userland proxy: listen tcp0.0.0.0:3306: bind: address already in use.

错误:为dockervel_mysql_1 无法重新启动容器c258b418c03cbd6ec02c349c12cf09403f0eaf42fa9248019af7860d037d6474:驱动程序无法在编程外部连接端点dockervel_mysql_1(da3dd576458aa1fe3af7b539c48b9d61d97432cf5e9ee02d78562851f53981ae):电子RROR启动用户级代理:听tcp0.0.0.0:3306:绑定:地址已经在使用。

I have to make LAravel app and to deliver a Dockerfile ,but i'm realy stuck with this. Before that I had a nightmare wile installing laravel on my machine.

我必须制作 LAravel 应用程序并提供 Dockerfile ,但我真的坚持这个。在此之前,我曾在我的机器上安装 Laravel 做噩梦。

I'm trying to get dockervel image and I'm following the steps here: http://www.spiralout.eu/2015/12/dockervel-laravel-development.html

我正在尝试获取 dockervel 图像,我正在按照以下步骤操作:http: //www.spiralout.eu/2015/12/dockervel-laravel-development.html

But when I run dartisan make:auth it gives this error above.

但是当我运行 dartisan make:auth 时,它会在上面给出这个错误。

I have tried to Change the default port in the docker-compose.yml

我试图更改 docker-compose.yml 中的默认端口

ports:

- "8084:80"

端口:

- "8084:80"

still nothing,also tried to stop apache2 (service apache2 stop)on my machine ,also tried docker-compose restartand removing docker container dockervel_mysql_1. I have to mantion that I have alredy one Laravel proj. in /var/www/laravel .

仍然什么都没有,还尝试在我的机器上停止 apache2 (服务 apache2 停止),还尝试了docker -compose restart并删除 docker 容器 dockervel_mysql_1。我不得不说我已经有一个 Laravel 项目了。在 /var/www/laravel 中。

Please help!

请帮忙!

采纳答案by Spiral Out

Probably you have already a MySQL service running in port 3306. You should close it first.
Then try to end docker-compose downand restart it with docker-compose up.
Remember also to change the permissions after you add a file in your project (like dartisan make:auth) with dpermit

可能您已经在端口 3306 中运行了一个 MySQL 服务。您应该先关闭它。
然后尝试结束docker-compose down并重新启动它docker-compose up
还记得在您的项目中添加文件(如dartisan make:auth)后更改权限dpermit

UPDATE:since you have changed the port to "8084" you should go to localhost:8084
If you see the apache default then you probably are browsing another server since dockervel is build upon nginx.
You have also probably have some gaps on Docker. Don't mix your local storage with docker storage. /var/wwwin a container is different than your local /var/www. in docker-compose.yml you mount the local ~/dockervel/wwwto containers /var/www.
I would suggest that you start all over again and revert the changes you've made to your apache server. Shut it down, you don't need it. Dockervel will provide you with an NginX server in a container.

更新:由于您已将端口更改为“8084”,您应该转到localhost:8084
如果您看到 apache 默认值,那么您可能正在浏览另一台服务器,因为 dockervel 是基于nginx.
您可能在 Docker 上也有一些差距。不要将本地存储与 docker 存储混合使用。/var/www容器中的/var/www. 在 docker-compose.yml 中,您将本地安装~/dockervel/www到容器/var/www
我建议您重新开始并恢复您对 apache 服务器所做的更改。关闭它,你不需要它。Dockervel 将在容器中为您提供 NginX 服务器。

回答by Per Mikkelsen

I had the same problem and

我有同样的问题

sudo netstat -nlpt |grep 3306

showed me the PID and which service it was started by (mysgld). Whenever I tried to kill the PID then it was started again. But the problem was fixed when I stopped the service by

向我展示了 PID 以及它由 (mysgld) 启动的服务。每当我试图杀死 PID 时,它就会再次启动。但是当我停止服务时问题得到了解决

sudo service mysql stop

Notice that you will have to use mysqland not mysqld.

请注意,您必须使用mysql而不是mysqld

I hope that this will do it for you - I was able to run docker-compose upwithout any problems

我希望这对你有用 - 我能够docker-compose up毫无问题地运行

回答by goodnesskay

On Ubuntu, running this command will stop your mysql from running for your docker container to work:

在 Ubuntu 上,运行此命令将阻止您的 mysql 为您的 docker 容器运行:

sudo service mysql stop  

Then, if your apache2 is running, you need to stop the service especially when you want to work with nginx:

然后,如果您的 apache2 正在运行,您需要停止该服务,尤其是当您想使用 nginx 时:

sudo service apache2 stop

Then, you can run your docker-compose up -d ...command

然后,您可以运行您的docker-compose up -d ...命令

回答by BMitch

The error you are seeing is from a local mysql instance listening on port 3306 (currently on pid 1370 from your comments). You won't be able to run a container that publishes on this host port while it's already in use by another process. Solutions are to either stop mysql on the local host, or to change/remove the published port in your container. If the port is only needed by other containers, you can leave it unpublished and they can communicate directly on the docker private network (by default, this is "bridge").

您看到的错误来自本地 mysql 实例,该实例侦听端口 3306(当前在您的评论中为 pid 1370)。当容器已被另一个进程使用时,您将无法运行在此主机端口上发布的容器。解决方案是在本地主机上停止 mysql,或者更改/删除容器中已发布的端口。如果该端口仅被其他容器需要,您可以不发布它,它们可以直接在 docker 专用网络上通信(默认情况下,这是“桥接”)。

回答by Hashmatullah Noorzai

So for me when I was trying to load and run MySQL image in docker container, I was getting the same error: enter image description here

因此,当我尝试在 docker 容器中加载和运行 MySQL 映像时,我遇到了相同的错误: 在此处输入图片说明

And even after stopping local mysql server in system preferences didn't help: enter image description hereCause the port 3306 was used by my tomcat server, so basically you have to make sure the port(in this case 3306) that the docker command wants to use should not be in use by any other service otherwise the command will fail

即使在系统首选项中停止本地 mysql 服务器后也没有帮助: 在此处输入图片说明因为端口 3306 被我的 tomcat 服务器使用,所以基本上你必须确保docker 命令想要使用的端口(在这种情况下是 3306)不应该被任何其他服务使用,否则命令将失败

回答by Ahmed Al Bermawy

You need to change the mysql port because you are installing mysql on your machine and it takes the default port 3306

您需要更改 mysql 端口,因为您正在机器上安装 mysql 并且它采用默认端口 3306

and now you are trying to make dockervel_mysql_1 run to the same port 3306 , this is why you see in the error "Address already in use"

现在你正试图让 dockervel_mysql_1 运行到同一个端口 3306 ,这就是你在错误中看到“地址已经在使用中”的原因

so if you change dockervel_mysql_1 port to 3307 for example it will works fine , without stopping the mysql that is running on you machine

因此,例如,如果您将 dockervel_mysql_1 端口更改为 3307,它将正常工作,而不会停止在您的机器上运行的 mysql

回答by jmojico

Running this command fixed the issue for me:

运行此命令为我解决了这个问题:

docker swarm leave --force

docker swarm leave --force

Explanation:I had started docker swarm service as a master node in my localhost. Swarm was taking network priority and making use of this ports already

说明:我在本地主机中启动了 docker swarm 服务作为主节点。Swarm 正在获取网络优先级并已经在使用这些端口