问题描述
我在Windows 10专业版中将docker用于Windows(版本18.03.0-ce-win59(16762)).在运行命令 docker-compose -up -d
之后,所有容器都可以正常运行.问题是当我重新启动docker服务时.然后,一旦重新启动,所有容器都将停止,当我运行命令 docker-compose start -d
时,将显示以下错误:
I'm using docker for windows (Version 18.03.0-ce-win59 (16762)) in a windows 10 pro. All the containers run ok after running the command docker-compose -up -d
. The problem is when I restart the docker service. Then, once restarted, all the containers are stoped and when I run the command docker-compose start -d
the following error is shown:
Error response from daemon: network ccccccccccccc not found
我不知道发生了什么.当我使用 run
和-restart = always
选项运行容器时,一切正常.重新启动时未显示任何错误.
I don't know what's happening. When I run the container using run
and the --restart=always
option everything works as expected. No error is shown on restart.
这是docker-compose文件:
This is the docker-compose file:
version: '3'
services:
service_1:
image: image1
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "1"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
service_2:
image: image2
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "2"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
service_3:
image: image3
restart: always
build:
context: C:/ProgramData/Docker/volumes/foo2
dockerfile: Dockerfile
args:
ENTRY: "4"
volumes:
- C:/ProgramData/Docker/volumes/foo1:C:/foo1
- C:/ProgramData/Docker/volumes/foo2:C:/foo2
dockerfile是这样的:
The dockerfiles are like this:
FROM microsoft/dotnet-framework:3.5
ARG ENTRY
ENV my_env=$ENTRY
WORKDIR C:\\foo2
ENTRYPOINT C:/foo2/app.exe %my_env%
推荐答案
我发现了如下编辑docker-compose.yml文件的可能解决方案:
I found a possible solution editing the docker-compose.yml file as follows:
version: '3'
services:
cm04:
image: tnc530_cm04
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC530
dockerfile: Dockerfile
args:
ENTRY: "1"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC530/bin/x86/Release:C:/adontec
cm06:
image: tnc620_cm06
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620
dockerfile: Dockerfile
args:
ENTRY: "2"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620/bin/x86/Release:C:/adontec
cm08:
image: tnc620_cm08
networks:
- test
privileged: false
restart: always
build:
context: C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620
dockerfile: Dockerfile
args:
ENTRY: "4"
volumes:
- C:/ProgramData/Docker/volumes/sqlite:C:/sqlite
- C:/ProgramData/Docker/volumes/adontec/LSV2_Lib/Heidenhain/TNC620/bin/x86/Release:C:/adontec
networks:
test:
external:
name: nat
如您所见,我创建了一个名为 test
的网络,该网络与外部网络 nat
链接.现在,当我重新启动Docker服务时,容器将正确启动.
As you can see I created a network called test
linked with the external network nat
. Now, when I restart the docker services the containers are started with no errors.
这篇关于重新启动Docker后,Docker Compose无法启动未找到的服务网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!