Skip to content

Commit cdae8fb

Browse files
author
sflxn
committed
Fixed attach for docker-compose up
When running docker-compose up, without -d, the attach path is exercised. We did not make the container VM attachable during ContainerCreate. We now ignore the attachStdout, attachStderr, and attachStdin params during container create, which is what Docker does too. Resolves vmware#4223
1 parent 9eed3d7 commit cdae8fb

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

lib/apiservers/engine/backends/container_proxy.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,9 @@ func dockerContainerCreateParamsToTask(id string, cc types.ContainerCreateConfig
10221022
// user
10231023
config.User = cc.Config.User
10241024

1025-
// attach
1026-
config.Attach = cc.Config.AttachStdin || cc.Config.AttachStdout || cc.Config.AttachStderr
1025+
// attach. Always set to true otherwise we cannot attach later.
1026+
// this tells portlayer container is attachable.
1027+
config.Attach = true
10271028

10281029
// openstdin
10291030
config.OpenStdin = cc.Config.OpenStdin

tests/test-cases/Group3-Docker-Compose/3-03-Docker-Compose-Basic.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ This test requires that a vSphere server is running and available
2929
16. Issue DOCKER_HOST=<VCH IP> docker-compose --file compose-rename.yml up -d
3030
17. Issue DOCKER_HOST=<VCH IP> docker-compose --file compose-rename.yml up -d --force-recreate
3131
18. Issue DOCKER_HOST=<VCH IP> docker-compose --file compose-rename.yml up -d
32+
19. Issue DOCKER_HOST=<VCH IP> docker-compose up (without -d)
33+
20. Issue DOCKER_HOST=<VCH IP> docker-compose stop on the above container
34+
21. Issue DOCKER_HOST=<VCH IP> docker-compose up (without -d) again
3235

3336
# Expected Outcome:
34-
* Step 4-18 should result in no errors
37+
* Step 4-21 should result in no errors
3538

3639
# Possible Problems:
3740
None

tests/test-cases/Group3-Docker-Compose/3-03-Docker-Compose-Basic.robot

+29-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ${yml} version: "2"\nservices:\n${SPACE}web:\n${SPACE}${SPACE}image: python:2.7
2323
${link-yml} version: "2"\nservices:\n${SPACE}redis1:\n${SPACE}${SPACE}image: redis:alpine\n${SPACE}${SPACE}container_name: redis1\n${SPACE}${SPACE}ports: ["6379"]\n${SPACE}web1:\n${SPACE}${SPACE}image: busybox\n${SPACE}${SPACE}container_name: a.b.c\n${SPACE}${SPACE}links:\n${SPACE}${SPACE}- redis1:aaa\n${SPACE}${SPACE}command: ["ping", "aaa"]
2424
${rename-yml-1} version: "2"\nservices:\n${SPACE}web:\n${SPACE}${SPACE}image: busybox\n${SPACE}${SPACE}command: ["/bin/top"]
2525
${rename-yml-2} version: "2"\nservices:\n${SPACE}web:\n${SPACE}${SPACE}image: ubuntu\n${SPACE}${SPACE}command: ["date"]
26+
${hello-yml} version: "2"\nservices:\n${SPACE}top:\n${SPACE}${SPACE}image: busybox\n${SPACE}${SPACE}container_name: top\n${SPACE}${SPACE}command: ["echo", "hello, world"]
2627

2728
*** Keywords ***
2829
Check Compose Logs
@@ -72,13 +73,19 @@ Compose Up while another container is running (ps filtering related)
7273
${rc} ${out}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} -f basic-compose.yml up -d
7374
Log ${out}
7475
Should Be Equal As Integers ${rc} 0
76+
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} --file basic-compose.yml down
77+
Log ${output}
78+
Should Be Equal As Integers ${rc} 0
7579

7680
Compose Up with link
7781
Run echo '${link-yml}' > link-compose.yml
7882
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} --file link-compose.yml up -d
7983
Log ${output}
8084
Should Be Equal As Integers ${rc} 0
8185
Wait Until Keyword Succeeds 10x 10s Check Compose Logs
86+
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} --file link-compose.yml down
87+
Log ${output}
88+
Should Be Equal As Integers ${rc} 0
8289

8390
Compose bundle creation
8491
${rc} Run And Return Rc docker-compose %{COMPOSE-PARAMS} --file basic-compose.yml pull
@@ -87,6 +94,9 @@ Compose bundle creation
8794
Log ${output}
8895
Should Contain ${output} Wrote bundle
8996
Should Be Equal As Integers ${rc} 0
97+
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} --file basic-compose.yml down
98+
Log ${output}
99+
Should Be Equal As Integers ${rc} 0
90100

91101
Compose up -d --force-recreate
92102
Run echo '${rename-yml-1}' > compose-rename.yml
@@ -99,6 +109,24 @@ Compose up -d --force-recreate
99109

100110
Compose up -d with a new image
101111
Run echo '${rename-yml-2}' > compose-rename.yml
102-
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} --file compose-rename.yml up -d
112+
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} --file compose-rename.yml up -d
113+
Log ${output}
114+
Should Be Equal As Integers ${rc} 0
115+
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} --file compose-rename.yml down
116+
Log ${output}
117+
Should Be Equal As Integers ${rc} 0
118+
119+
Compose up in foreground (attach path)
120+
Run echo '${hello-yml}' > hello-compose.yml
121+
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} -f hello-compose.yml pull
122+
Should Be Equal As Integers ${rc} 0
123+
Log ${output}
124+
125+
# Bring up the compose app and wait till they're up and running
126+
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} -f hello-compose.yml up
127+
Log ${output}
128+
Should Contain ${output} hello, world
129+
130+
${rc} ${output}= Run And Return Rc And Output docker-compose %{COMPOSE-PARAMS} -f hello-compose.yml down
103131
Log ${output}
104132
Should Be Equal As Integers ${rc} 0

0 commit comments

Comments
 (0)