Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

add support for service_completed_successfully#1502

Merged
ndeloof merged 1 commit intomainfrom
init_container
Apr 7, 2021
Merged

add support for service_completed_successfully#1502
ndeloof merged 1 commit intomainfrom
init_container

Conversation

@ndeloof
Copy link
Collaborator

@ndeloof ndeloof commented Apr 7, 2021

What I did
introduced support for service_completed_successfully
(aka init container)

Related issue
close #1499

@github-actions github-actions bot added the local Local context (moby) label Apr 7, 2021
@ndeloof ndeloof force-pushed the init_container branch 3 times, most recently from d61f4a8 to 9b4dd15 Compare April 7, 2021 12:14
@ndeloof ndeloof requested a review from aiordache April 7, 2021 12:27
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@aiordache
Copy link
Contributor

I compared the behaviour with docker-compose and it looks like, in one case, the container is being created and started after the dependency exits (docker-compose) while in the other case it is being created in the same time as the dependency but started after the dependency exits (docker compose).

[example]$ cat docker-compose.yml 
services:
  frontend:
    image: nginx
    ports:
      - 8888:80
    depends_on:
      backend:
        condition: service_completed_successfully
  backend:
    image: busybox
    command: sh -c 'sleep 10'
[example]$ docker-compose up -d
Creating network "example_default" with the default driver
Creating example_backend_1 ... done
Creating example_frontend_1 ... done
[example]$ docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                     PORTS                  NAMES
fc81eefac293   nginx     "/docker-entrypoint.…"   4 seconds ago    Up 3 seconds               0.0.0.0:8888->80/tcp   example_frontend_1
1278dc861a94   busybox   "sh -c 'sleep 10'"       15 seconds ago   Exited (0) 4 seconds ago                          example_backend_1
[example]$ docker compose up -d
[+] Running 3/3
 ⠿ Network "example_default"     Created                                                                                 0.0s
 ⠿ Container example_backend_1   Started                                                                                 0.3s
 ⠿ Container example_frontend_1  Started                                                                                10.9s
[example]$ docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                     PORTS                  NAMES
c825111982dd   nginx     "/docker-entrypoint.…"   14 seconds ago   Up 2 seconds               0.0.0.0:8888->80/tcp   example_frontend_1
1babc6992a3b   busybox   "sh -c 'sleep 10'"       14 seconds ago   Exited (0) 3 seconds ago                          example_backend_1

@ndeloof
Copy link
Collaborator Author

ndeloof commented Apr 7, 2021

create vs start order is (obviously) not defined by compose-spec, and should not have any impact afaict

@ndeloof ndeloof merged commit 0e8a56b into main Apr 7, 2021
@ndeloof ndeloof deleted the init_container branch April 7, 2021 15:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

local Local context (moby)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add support for Init Containers

3 participants