Docker compose can not start service network not found after restart docker

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

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!


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.