Docker killing 3306 usage 端口导致崩溃docker
Docker killing 3306 usage port cause of crashing docker
我正在使用 MaxOs
,在安装 Docker
之后,我尝试安装 LaraDock
、运行 这个命令,它在 LaraDoc
文档中:
laradock % docker-compose up -d nginx mariadb phpmyadmin redis workspace
return 这个错误:
laradock_mariadb_1 is up-to-date
laradock_docker-in-docker_1 is up-to-date
laradock_redis_1 is up-to-date
Starting laradock_mysql_1 ...
Starting laradock_mysql_1 ... error
WARNING: Host is already in use by another container
ERROR: for laradock_mysql_1 Cannot start service mysql: driver failed programming external
connectivity on endpoint laradock_mysql_1 (a75f179cd36ac95540f346d1c75ff105904cc8717690152ac90b92383c847a3b): Bind for 0.0.0.0:3306 failed: port is already allocated
Starting laradock_workspace_1 ... error
ERROR: for laradock_workspace_1 Cannot start service workspace: driver failed programming external connectivity on endpoint laradock_workspace_1 (fd6a03d680c668acae7f6db40ad7f5d9951a267cdf7e7686f66f751f91cece17): Bind for 0.0.0.0:8080 failed: port is already allocated
ERROR: for mysql Cannot start service mysql: driver failed programming external connectivity on endpoint laradock_mysql_1 (a75f179cd36ac95540f346d1c75ff105904cc8717690152ac90b92383c847a3b): Bind for 0.0.0.0:3306 failed: port is already allocated
ERROR: for workspace Cannot start service workspace: driver failed programming external connectivity on endpoint laradock_workspace_1 (fd6a03d680c668acae7f6db40ad7f5d9951a267cdf7e7686f66f751f91cece17): Bind for 0.0.0.0:8080 failed: port is already allocated
当我尝试终止 3306
导致崩溃的 Docker
应用程序时
sudo kill `sudo lsof -t -i:3306`
LaraDock
配置:
...
ports:
- "${MYSQL_PORT}:3306"
...
ports:
- "${MARIADB_PORT}:3306"
您应该保证 MYSQL_PORT
和 MARIADB_PORT
具有不同的值,否则 Docker 将尝试在主机网络上为两者分配相同的端口。
除此之外,当您不“发布”任何端口时,Docker 上的容器可以 运行 使用自己的端口,就像很多容器 运行 端口 80
,因为默认情况下,每个容器都有一个网络接口。
注意缩进,总是使用 spaces
而不是 tabs
:
...
version: '3.0'
services:
mysql:
image: mysql:5.7
ports:
- "3306:3306"
mariadb:
image: mariadb:10.4
ports:
- "3307:3306"
我正在使用 MaxOs
,在安装 Docker
之后,我尝试安装 LaraDock
、运行 这个命令,它在 LaraDoc
文档中:
laradock % docker-compose up -d nginx mariadb phpmyadmin redis workspace
return 这个错误:
laradock_mariadb_1 is up-to-date
laradock_docker-in-docker_1 is up-to-date
laradock_redis_1 is up-to-date
Starting laradock_mysql_1 ...
Starting laradock_mysql_1 ... error
WARNING: Host is already in use by another container
ERROR: for laradock_mysql_1 Cannot start service mysql: driver failed programming external
connectivity on endpoint laradock_mysql_1 (a75f179cd36ac95540f346d1c75ff105904cc8717690152ac90b92383c847a3b): Bind for 0.0.0.0:3306 failed: port is already allocated
Starting laradock_workspace_1 ... error
ERROR: for laradock_workspace_1 Cannot start service workspace: driver failed programming external connectivity on endpoint laradock_workspace_1 (fd6a03d680c668acae7f6db40ad7f5d9951a267cdf7e7686f66f751f91cece17): Bind for 0.0.0.0:8080 failed: port is already allocated
ERROR: for mysql Cannot start service mysql: driver failed programming external connectivity on endpoint laradock_mysql_1 (a75f179cd36ac95540f346d1c75ff105904cc8717690152ac90b92383c847a3b): Bind for 0.0.0.0:3306 failed: port is already allocated
ERROR: for workspace Cannot start service workspace: driver failed programming external connectivity on endpoint laradock_workspace_1 (fd6a03d680c668acae7f6db40ad7f5d9951a267cdf7e7686f66f751f91cece17): Bind for 0.0.0.0:8080 failed: port is already allocated
当我尝试终止 3306
导致崩溃的 Docker
应用程序时
sudo kill `sudo lsof -t -i:3306`
LaraDock
配置:
...
ports:
- "${MYSQL_PORT}:3306"
...
ports:
- "${MARIADB_PORT}:3306"
您应该保证 MYSQL_PORT
和 MARIADB_PORT
具有不同的值,否则 Docker 将尝试在主机网络上为两者分配相同的端口。
除此之外,当您不“发布”任何端口时,Docker 上的容器可以 运行 使用自己的端口,就像很多容器 运行 端口 80
,因为默认情况下,每个容器都有一个网络接口。
注意缩进,总是使用 spaces
而不是 tabs
:
...
version: '3.0'
services:
mysql:
image: mysql:5.7
ports:
- "3306:3306"
mariadb:
image: mariadb:10.4
ports:
- "3307:3306"