Docker部署服务报错及解决方案

报错1

报错信息如下图所示:docker-compose idea CreateProcess error=2, 系统找不到指定的文件
在这里插入图片描述
解决方案:IDEA执行docker-compose命令需要对应的可执行文件,而Windows上面没有这个命令。所以需要下载Docker,引用Docker安装目录下docker-compose命令。
如图,将红框的内容替换为C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe
在这里插入图片描述

报错2

Docker部署xxx-xxxxx-xxx服务,报错信息如下:

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Creating xxx-xxxxx-xxx ... 

ERROR: for xxx-xxxxx-xxx  "host" network_mode is incompatible with port_bindings

ERROR: for xxx-xxxxx-xxx  "host" network_mode is incompatible with port_bindings
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 81, in main
  File "compose\cli\main.py", line 203, in perform_command
  File "compose\metrics\decorator.py", line 18, in wrapper
  File "compose\cli\main.py", line 1186, in up
  File "compose\cli\main.py", line 1166, in up
  File "compose\project.py", line 697, in up
  File "compose\parallel.py", line 108, in parallel_execute
  File "compose\parallel.py", line 206, in producer
  File "compose\project.py", line 679, in do
  File "compose\service.py", line 559, in execute_convergence_plan
  File "compose\service.py", line 473, in _execute_convergence_create
  File "compose\parallel.py", line 108, in parallel_execute
  File "compose\parallel.py", line 206, in producer
  File "compose\service.py", line 478, in <lambda>
  File "compose\service.py", line 457, in create_and_start
  File "compose\service.py", line 330, in create_container
  File "compose\service.py", line 939, in _get_container_create_options
  File "compose\service.py", line 1014, in _get_container_host_config
  File "docker\api\container.py", line 598, in create_host_config
  File "docker\types\containers.py", line 338, in __init__
docker.errors.InvalidArgument: "host" network_mode is incompatible with port_bindings
[24496] Failed to execute script docker-compose
Failed to deploy 'Compose: xxx-app': `docker-compose` process finished with exit code -1

报错原因: "host" network_mode is incompatible with port_bindings(host网络模式与端口映射不兼容)
错误定位:Docker compose file(docker-compose-dev.yml),内容如下所示

version: "2"
services:
  xxx-xxxxx-xxx:
    build: .
    	...
    network_mode: host
    image: xxx-xxxxx-xxx
    ports:
      - 9010:9010
    ...

network_mode: host网络模式设置为host,即host模式下容器不会获得一个独立的network namespace,而是与宿主机共用一个。这就意味着容器不会有自己的网卡信息,而是使用宿主机的。在这种情况下,所有端口是与宿主机同步,我们访问宿主机端口就能访问我们的容器,再作端口映射是本机映射到本机,多此一举。
解决方案:修改docker-compose-dev.yml文件,删除ports配置

version: "2"
services:
  xxx-xxxxx-xxx:
    build: .
    	...
    network_mode: host
    image: xxx-xxxxx-xxx
    ...

相关链接:https://blog.csdn.net/mahui_1980/article/details/114972555

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要解决Docker启动Redis报错的问题,可以尝试以下两种方法: 方法一:设置stop-writes-on-bgsave-error值为no 1. 打开配置文件emqx_auth_redis.conf,配置redis连接地址。 2. 进入解压目录,执行docker build .来生成镜像。 3. 执行docker run命令启动服务,并指定端口号,例如:docker run --name emqx -p 1883:1883 -p 8883:8883 -p 18083:18083 -d 镜像ID。 4. 登录Redis:redis-cli -h 127.0.0.1 -p 6379 5. 在Redis命令行中执行config set stop-writes-on-bgsave-error no来设置stop-writes-on-bgsave-error的值为no。 方法二:修改redis.conf配置文件 1. 使用vim打开Redis的配置文件redis.conf。 2. 找到stop-writes-on-bgsave-error这一行的配置项。 3. 将yes修改为no。 4. 保存并关闭文件。 5. 重启Redis服务,使修改的配置生效。 通过以上两种方法中的任意一种,您应该能够解决Docker启动Redis报错的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [docker dockerFile 一键部署 emqx](https://download.csdn.net/download/qq_39231899/82331253)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [docker中启动redis整合Springboot提示错误解决方案](https://blog.csdn.net/administratop/article/details/126498441)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值