cleanUrl: /posts/network-not-found-error
share: true

최근에 도커가 많은 power 를 잡아먹는데 docker 를 사용하지 않아서 꺼두었다가 다시켜니 굉장히 당황스러운 error 가 발생했다. 다음에도 또 이런 에러가 날것 같으니 간단히 메모해두려고 한다.

이 에러는 docker-compose 에서 발생했다.

<script async src="<https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js>"></script>
<ins class="adsbygoogle"
     style="display:block; width: 100%;"
     data-ad-format="fluid"
     data-ad-layout-key="-fb+5w+4e-db+86"
     data-ad-client="pub-8946038251809377"
     data-ad-slot="5490836264"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
Error response from daemon: network xxxxxxxxxxxxxxx not found

일단 발생 이유는 docker network 가 변경되어 발생된 에러이다.

또한 변경되었다면 기존이 docker instance 가 삭제 되어야 하는데 (원래는 삭제되고 다시 만들어지는 과정이 수반되어야 한다) 삭제가 되지 않고 무엇인가가 남아있었기 때문에 발생한 에러이다.

docker ps -qa

명령어를 사용해보자 다음과 같이 docker 의 id 만 반환받는다

243067a5c7c8
7904f1d1ad37
21ec05490954
36f3cbef27e9
5cf911c70b6a
c216d916c4d2

docker ps 의 옵션은 다음과 같다

Flag shorthand -h has been deprecated, please use --help

Usage:  docker ps [OPTIONS]

List containers

Options:
  -a, --all             Show all containers (default shows just running)
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print containers using a Go template
  -n, --last int        Show n last created containers (includes all states) (default -1)
  -l, --latest          Show the latest created container (includes all states)
      --no-trunc        Don't truncate output
  -q, --quiet           Only display container IDs
  -s, --size            Display total file sizes

여기서 나타나는 모든 container 들을 삭제하고 다시 실행하고자 했던 docker-compose 를 실행하면 된다.

docker rm $(docker ps -qa)

보통 id 만 list 로 반환하는 옵션을 위와 같이 $() 로 받아 wrapper command 에 매개변수로 전달하는 용도로 사용한다

| 까지 이용한다면 특정 container 만 제거하는 것도 가능해지기 때문에 익숙해지면 편리하다

출처

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