During first execution, everything works fine and both the containers (say X-mongo & X-redis) are created successfully. But when I make another call to create new containers with different container names (say Y-mongo & Y-Redis), the code execution fails at a certain point for second container (Y-Redis) and I am not able to exercise the logic ahead. Following is the trace that I see:
2019/05/30 09:35:22 Inside CreateDockerContainer
2019/05/30 09:35:22 top12-mongo
2019/05/30 09:35:22 http: panic serving 127.0.0.1:57786: Error response from daemon: Conflict. The container name "/top12-mongo" is already in use by container "1e5d869cbdb13e10c85e216419d0dd7982000a9a2c5f6782b8ec03d5dbb7e577". You have to remove (or rename) that container to be able to reuse that name.
goroutine 9 [running]:
net/http.(*conn).serve.func1(0xc00023f360)
/usr/local/go/src/net/http/server.go:1769 +0x139
panic(0x745bc0, 0xc000376df0)
/usr/local/go/src/runtime/panic.go:522 +0x1b5
webserver/dockercontainer.CreateDockerContainer(0x82e4e0, 0xc0000180d8, 0xc0002aaef2, 0x5, 0xc000375600, 0x5, 0xc000375640, 0x0, 0x0, 0x0, ...)
/home/nsadmin/go/src/webserver/dockercontainer/dockercontainer.go:88 +0x453
main.sethandler(0x82db60, 0xc0003841c0, 0xc0000ddc00)
/home/nsadmin/go/src/webserver/main.go:253 +0xc71
net/http.HandlerFunc.ServeHTTP(0x7c9dd8, 0x82db60, 0xc0003841c0, 0xc0000ddc00)
/usr/local/go/src/net/http/server.go:1995 +0x44
webserver/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc0001000c0, 0x82db60, 0xc0003841c0, 0xc0000dda00)
/home/nsadmin/go/src/webserver/vendor/github.com/gorilla/mux/mux.go:212 +0xe3
net/http.serverHandler.ServeHTTP(0xc00007aea0, 0x82db60, 0xc0003841c0, 0xc0000dda00)
/usr/local/go/src/net/http/server.go:2774 +0xa8
net/http.(*conn).serve(0xc00023f360, 0x82e4a0, 0xc000272940)
/usr/local/go/src/net/http/server.go:1878 +0x851
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2884 +0x2f4
Please help me know if I am doing something wrong here or there is a defect.
I am trying to build multiple container using go-docker.
Following is the call I am making:
During first execution, everything works fine and both the containers (say X-mongo & X-redis) are created successfully. But when I make another call to create new containers with different container names (say Y-mongo & Y-Redis), the code execution fails at a certain point for second container (Y-Redis) and I am not able to exercise the logic ahead. Following is the trace that I see:
Please help me know if I am doing something wrong here or there is a defect.