How to wait until `docker start` is finished?

后端 未结 2 1161
走了就别回头了
走了就别回头了 2021-01-22 06:19

When I run docker start, it seems the container might not be fully started at the time the docker start command returns. Is it so?

Is there a w

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-22 06:27

    Disclaimer, I'm not an expert in Docker, and will be glad to know by myself whether a better solution exists.

    The docker system doesn't really know that container "may not be fully started".

    So, unfortunately, there is nothing to do with this in docker. Usually, the commands used by the creator of the docker image (in the Dockerfile) are supposed to be organized in a way that the container will be usable once the docker start command ends on the image, and its the best way. However, it's not always the case.

    Here is an example:

    A Localstack, which is a set of services for local development with AWS has a docker image, but once its started, for example, S3 port is not ready to get connections yet. From what I understand a non-ready-although-exposed port will be a typical situation that you refer to.

    So, out of my experience, in the application that talks to docker process the attempt to connect to the server port should be enclosed with retries and once it's available.

提交回复
热议问题