@@ -37,7 +37,7 @@ type DockerAdapter struct {
3737}
3838
3939func (d * DockerAdapter ) GetContainerStatus (basePath string , name string ) (CloudControlStatus , error ) {
40- containerName := fmt .Sprintf ("%s_cli_1 " , name )
40+ containerName := fmt .Sprintf ("%s%scli%s1 " , name , api . Separator , api . Separator )
4141 c := d .getClient ()
4242 notFound := regexp .MustCompile ("No such container" )
4343 if i , err := c .ContainerInspect (context .Background (), containerName ); err != nil {
@@ -86,7 +86,7 @@ func (d *DockerAdapter) GetContainerStatus(basePath string, name string) (CloudC
8686}
8787
8888func (d * DockerAdapter ) RunCloudControl (_ string , name string , consoleWidth uint , consoleHeight uint ) (* ContainerExec , error ) {
89- containerName := fmt .Sprintf ("%s_cli_1 " , name )
89+ containerName := fmt .Sprintf ("%s%scli%s1 " , name , api . Separator , api . Separator )
9090 consoleSize := [2 ]uint {consoleHeight , consoleWidth }
9191 return & ContainerExec {
9292 exec : func (stdin io.Reader , stdout io.Writer ) error {
@@ -135,65 +135,74 @@ func (d *DockerAdapter) RunCloudControl(_ string, name string, consoleWidth uint
135135 }
136136
137137 go func (c net.Conn ) {
138+ active := true
138139 s := bufio .NewReader (c )
139140 for {
140141 select {
141142 case <- quitWriter :
142143 return
143144 default :
144- if b , err := s .ReadByte (); err != nil {
145- logrus .Errorf ("error reading from Docker: %s" , err )
146- return
147- } else {
148- if _ , err := stdout .Write ([]byte {b }); err != nil {
149- logrus .Errorf ("error writing to stdout: %s" , err )
145+ if active {
146+ if b , err := s .ReadByte (); err != nil {
147+ logrus .Errorf ("error reading from Docker: %s" , err )
148+ active = false
149+ } else {
150+ if _ , err := stdout .Write ([]byte {b }); err != nil {
151+ logrus .Errorf ("error writing to stdout: %s" , err )
152+ }
150153 }
151154 }
152155 }
153156 }
154157 }(execResponse .Conn )
155158
156159 go func (c net.Conn ) {
160+ active := true
157161 s := bufio .NewReader (stdin )
158162 for {
159163 select {
160164 case <- quitReader :
161165 return
162166 default :
163- if b , err := s .ReadByte (); err != nil {
164- logrus .Errorf ("error reading from Docker: %s" , err )
165- return
166- } else {
167- if _ , err := c .Write ([]byte {b }); err != nil {
168- logrus .Errorf ("error writing to Docker: %s" , err )
169- return
167+ if active {
168+ if b , err := s .ReadByte (); err != nil {
169+ logrus .Errorf ("error reading from Docker: %s" , err )
170+ active = false
171+ } else {
172+ if _ , err := c .Write ([]byte {b }); err != nil {
173+ logrus .Errorf ("error writing to Docker: %s" , err )
174+ active = false
175+ }
170176 }
171177 }
172178 }
173179 }
174180 }(execResponse .Conn )
175181
176182 go func () {
183+ active := true
177184 width := consoleWidth
178185 height := consoleHeight
179186 for {
180187 select {
181188 case <- quitTermResize :
182189 return
183190 default :
184- if w , err := term .GetWinsize (fd ); err != nil {
185- logrus .Errorf ("error getting terminal size: %s" , err )
186- return
187- } else {
188- if w .Width != uint16 (width ) || w .Height != uint16 (height ) {
189- width = uint (w .Width )
190- height = uint (w .Height )
191- if err := dockerCli .ContainerExecResize (context .Background (), executeID , types.ResizeOptions {
192- Width : width ,
193- Height : height ,
194- }); err != nil {
195- logrus .Errorf ("error resizing container terminal: %s" , err )
196- return
191+ if active {
192+ if w , err := term .GetWinsize (fd ); err != nil {
193+ logrus .Errorf ("error getting terminal size: %s" , err )
194+ active = false
195+ } else {
196+ if w .Width != uint16 (width ) || w .Height != uint16 (height ) {
197+ width = uint (w .Width )
198+ height = uint (w .Height )
199+ if err := dockerCli .ContainerExecResize (context .Background (), executeID , types.ResizeOptions {
200+ Width : width ,
201+ Height : height ,
202+ }); err != nil {
203+ logrus .Errorf ("error resizing container terminal: %s" , err )
204+ active = false
205+ }
197206 }
198207 }
199208 }
@@ -270,8 +279,6 @@ func (d *DockerAdapter) getClient() client.Client {
270279func (d * DockerAdapter ) getComposeBackend () api.Service {
271280 if d .composeBackend == nil {
272281 cl := d .getClient ()
273- // ensure old docker-compose compatibility
274- api .Separator = "_"
275282 if c , err := command .NewDockerCli (command .WithAPIClient (& cl ), command .WithDefaultContextStoreConfig ()); err != nil {
276283 panic (fmt .Sprintf ("Can not connect to Docker API: %s" , err .Error ()))
277284 } else {
0 commit comments