Docker compose can not start service network not found after restart docker
Asked Answered
F

5

14

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

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.

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

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%
Flanagan answered 9/7, 2018 at 9:37 Comment(0)
F
5

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

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.

Flanagan answered 23/7, 2018 at 10:38 Comment(1)
This GitHub issue is tracking the same problem. Adding the networks section to the docker-compose fixed the issue for me.Okwu
K
22

The network has changed. I used docker network prune command to meet the same problem.Recreate the container would fix the problem. Docker would set up the network again for the new containers.

#remove all containers
docker rm $(docker ps -qa)
#or
docker system prune
Kanarese answered 18/6, 2019 at 0:46 Comment(0)
H
10

There might be some old container instances which were not removed. Check the instances with

docker container ls -a

You might get output like this if you have some instances which were not removed

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                   PORTS               NAMES
8b4678e6666b        b4a75a01d539        "/bin/sh -c 'eval `s…"   6 weeks ago         Exited (1) 6 weeks ago                       zealous_allen
ee862a3418f2        1eaaf48e9b42        "/bin/sh -c 'eval `s…"   6 weeks ago         Exited (1) 6 weeks ago                       jolly_torvalds

Remove the containers by the container id

docker container rm 8b4678e6666b
docker container rm ee862a3418f2 

Now start your container with docker-compose file This worked for me. Hope it helps!

Hokeypokey answered 23/7, 2019 at 12:28 Comment(1)
Maybe just removing the network could be a softer initial approach?Zagreb
F
5

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

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.

Flanagan answered 23/7, 2018 at 10:38 Comment(1)
This GitHub issue is tracking the same problem. Adding the networks section to the docker-compose fixed the issue for me.Okwu
A
1

Alternatively, you can just open your docker app and manually delete the containers. Then run docker-compose up on your terminal. Now it should be working. Go to the port either 9000 or 9001 or whichever port you are using and see if minio is actually running.

Analogue answered 1/4, 2021 at 10:16 Comment(0)
K
0

This fixed the issue for me:

docker network connect existingNetworkName containerName
Kraemer answered 24/7 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.