What docker-compose is doing

More than 3 years have passed since last update.


docker-compose up

docker-compose up does followings by the condition:


In case there's already the container



  • stop running container


  • create a new container as middle container


  • start middle container with volumes_from old container


    • The middle container's data is overwritten by old container

    • So it's stateful




  • wait middle container


  • remove old container


  • start another new container as final container with volumes_from middle container


  • remove middle container

Recreating dockerenvironment_web_1...

docker stop <- (u'04f067454c15a7e28302162ca6a8e9be35479a91b42ccc816dc08494d2d583d0')
docker stop -> None
docker create_container <- (entrypoint=[u'/bin/echo'], image=u'myapp_web:latest', detach=True, command=[])
docker create_container -> {u'Id': u'5d34728f3104dd30ece803928de8ab52e72213150f514fe4db87062eab891191',
u'Warnings': None}
docker inspect_container <- (u'5d34728f3104dd30ece803928de8ab52e72213150f514fe4db87062eab891191')
docker inspect_container -> {u'AppArmorProfile': u'',
u'Args': [],
u'Config': {u'AttachStderr': False,
u'AttachStdin': False,
u'AttachStdout': False,
u'Cmd': [],
u'CpuShares': 0,
u'Cpuset': u'',
u'Domainname': u'',
u'Entrypoint': [u'/bin/echo'],
...
docker start <- (u'5d34728f3104dd30ece803928de8ab52e72213150f514fe4db87062eab891191', volumes_from=u'04f067454c15a7e28302162ca6a8e9be35479a91b42ccc816dc08494d2d583d0')
docker start -> None
docker wait <- (u'5d34728f3104dd30ece803928de8ab52e72213150f514fe4db87062eab891191')
docker wait -> 0
docker remove_container <- (u'04f067454c15a7e28302162ca6a8e9be35479a91b42ccc816dc08494d2d583d0')
docker remove_container -> None
docker containers <- (all=True)
docker containers -> (list with 99 items)
docker create_container <- (environment={'RAILS_ENV': 'staging', 'TMPDIR': '/tmp'}, image=u'myapp_web:latest', detach=False, ports=[u'80'], name=u'dockerenvironment_web_1')
docker create_container -> {u'Id': u'a851722e1a60ee857c660253e3f7ca2c70fa023442fb1c3ebc38686fcf86fca7',
u'Warnings': None}
docker inspect_container <- (u'a851722e1a60ee857c660253e3f7ca2c70fa023442fb1c3ebc38686fcf86fca7')
docker inspect_container -> {u'AppArmorProfile': u'',
u'Args': [],
u'Config': {u'AttachStderr': True,
u'AttachStdin': False,
u'AttachStdout': True,
u'Cmd': [u'./start.sh'],
u'CpuShares': 0,
u'Cpuset': u'',
u'Domainname': u'',
u'Entrypoint': None,
...
docker containers <- (all=False)
docker containers -> (list with 3 items)
docker containers <- (all=False)
docker containers -> (list with 3 items)
docker containers <- (all=True)
docker containers -> (list with 100 items)
docker start <- (u'a851722e1a60ee857c660253e3f7ca2c70fa023442fb1c3ebc38686fcf86fca7', links=[(u'dockerenvironment_redis_1', 'redis'), (u'dockerenvironment_redis_1', u'dockerenvironment_redis_1'), (u'dockerenvironment_redis_1', u'redis_1'), (u'dockerenvironment_postgres_1', 'postgres'), (u'dockerenvironment_postgres_1', u'dockerenvironment_postgres_1'), (u'dockerenvironment_postgres_1', u'postgres_1')], cap_add=None, restart_policy=None, dns_search=None, network_mode=u'bridge', binds={}, dns=None, volumes_from=[u'c90dd2633d4fc9c25804147f0bb9a3adf60bed37f14347158531c28e2beccd7a', u'5d34728f3104dd30ece803928de8ab52e72213150f514fe4db87062eab891191'], port_bindings={u'80': [u'80']}, cap_drop=None, privileged=False)
docker start -> None
docker remove_container <- (u'5d34728f3104dd30ece803928de8ab52e72213150f514fe4db87062eab891191')
docker remove_container -> None
docker containers <- (all=True)
docker containers -> (list with 99 items)


In case there isn't the container yet



  • create container


  • start container

Creating dockerenvironment_myapp_1...

docker containers <- (all=True)
docker containers -> (list with 99 items)
docker create_container <- (name=u'dockerenvironment_myapp_1', image=u'myappservice_web:latest', environment={'RACK_ENV': 'staging'}, volumes={u'/usr/src/app/myapp-service/db': {}}, detach=False, ports=[u'9292'])
docker create_container -> {u'Id': u'd831bf11447dacaf291dd57e5cf72964d41403325cb080546186c36e2d1106df',
u'Warnings': None}
docker inspect_container <- (u'd831bf11447dacaf291dd57e5cf72964d41403325cb080546186c36e2d1106df')
docker inspect_container -> {u'AppArmorProfile': u'',
u'Args': [],
u'Config': {u'AttachStderr': True,
u'AttachStdin': False,
u'AttachStdout': True,
u'Cmd': [u'./start.sh'],
u'CpuShares': 0,
u'Cpuset': u'',
u'Domainname': u'',
u'Entrypoint': None,
...
docker containers <- (all=False)
docker containers -> (list with 4 items)
docker containers <- (all=False)
docker containers -> (list with 4 items)
docker containers <- (all=True)
docker containers -> (list with 100 items)
docker start <- (u'd831bf11447dacaf291dd57e5cf72964d41403325cb080546186c36e2d1106df', links=[(u'dockerenvironment_redis_1', 'redis'), (u'dockerenvironment_redis_1', u'dockerenvironment_redis_1'), (u'dockerenvironment_redis_1', u'redis_1'), (u'dockerenvironment_postgres_1', 'postgres'), (u'dockerenvironment_postgres_1', u'dockerenvironment_postgres_1'), (u'dockerenvironment_postgres_1', u'postgres_1')], cap_add=None, restart_policy=None, dns_search=None, network_mode=u'bridge', binds={}, dns=None, volumes_from=[u'c90dd2633d4fc9c25804147f0bb9a3adf60bed37f14347158531c28e2beccd7a'], port_bindings={u'9292': [u'9292']}, cap_drop=None, privileged=False)
docker start -> None
docker containers <- (all=True)
docker containers -> (list with 100 items)