I used docker-compose to create docker, but it always blocked.
At the sametime, The docker status is 'Created'. Why?
I had set COMPOSE_HTTP_TIMEOUT=1200
What commands are you running?
Same issue. I used docker python SDK version 2.1.0. The status is always "created", it doesn't show "running" even thought it shows UP on both CLI and Kitematic.
@rxforces Same question - what commands are you running?
I am following the doc: https://docker-py.readthedocs.io/en/stable/containers.html
After I create or run a container using client.container.create() or run(), but container_object.status is always "created". I did try to wait for 5~30 seconds and check status again, it is still "created". Meanwhile, "docker ps" shows "UP", Kitematics shows "RUNNING".
Below is my code, it never goes inside While loop because the status is "created".
...
try:
container = client.containers.create(json['image'], command=None, name=name, environment=env)
except (docker.errors.ContainerError, docker.errors.ImageNotFound, docker.errors.APIError) as e:
print e
return
if container:
container.start()
# wait for 30 seconds before container status update
for i in xrange(30):
time.sleep(1)
sys.stdout.write('!')
sys.stdout.flush()
timeout = 5
print container.status
while container.status == 'running':
time.sleep(1)
timeout = timeout + 1
if timeout < int(json['timeout']):
sys.stdout.write('!')
sys.stdout.flush()
else:
print("...Timeout")
container.stop()
@rxforces You're in the wrong repo - this is for Compose issues.
However to answer your question, you need to call container.reload()
to update the status
property.
HTH.
Works. It makes perfect sense now. Thanks a lot!
Just wanted to say that @shin- 's comment helped me too. It wasn't clear to me what is the created
state (it's not really mentioned anywhere) or that I need to call container.reload()
to get the right state (running
, etc.)
Would be great if the doc can clarify a bit more on this.
Most helpful comment
@rxforces You're in the wrong repo - this is for Compose issues.
However to answer your question, you need to call
container.reload()
to update thestatus
property.HTH.