From 2eec1fd109d8d84de6990493c6f339981b630554 Mon Sep 17 00:00:00 2001 From: Aaron Pham <29749331+aarnphm@users.noreply.github.com> Date: Wed, 31 Aug 2022 15:37:37 -0700 Subject: [PATCH] docs: fix bentoml containerize command help message (#2957) Co-authored-by: Sauyon Lee <2347889+sauyon@users.noreply.github.com> --- bentoml/bentos.py | 13 +++++++++---- bentoml_cli/containerize.py | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/bentoml/bentos.py b/bentoml/bentos.py index 2835f1b27fd..da441bcde65 100644 --- a/bentoml/bentos.py +++ b/bentoml/bentos.py @@ -380,7 +380,7 @@ def build_bentofile( @inject def containerize( tag: Tag | str, - docker_image_tag: str | t.List[str] | None = None, + docker_image_tag: t.List[str] | None = None, *, add_host: dict[str, str] | None = None, allow: t.List[str] | None = None, @@ -418,7 +418,7 @@ def containerize( bento = _bento_store.get(tag) if not docker_image_tag: - docker_image_tag = str(bento.tag) + docker_image_tag = [str(bento.tag)] dockerfile_path = os.path.join("env", "docker", "Dockerfile") @@ -465,9 +465,14 @@ def containerize( ) return False else: - logger.info(f'Successfully built docker image "{docker_image_tag}"') logger.info( - f'To run your newly built Bento container, use: "docker run -it --rm -p 3000:3000 {docker_image_tag}"' + 'Successfully built docker image for "%s" with tags "%s"', + str(bento.tag), + ",".join(docker_image_tag), + ) + logger.info( + 'To run your newly built Bento container, use one of the above tags, and pass it to "docker run". i.e: "docker run -it --rm -p 3000:3000 %s"', + docker_image_tag[0], ) return True diff --git a/bentoml_cli/containerize.py b/bentoml_cli/containerize.py index 1a7df808985..e6964ca23ec 100644 --- a/bentoml_cli/containerize.py +++ b/bentoml_cli/containerize.py @@ -196,29 +196,29 @@ def containerize( # type: ignore BENTO is the target BentoService to be containerized, referenced by its name and version in format of name:version. For example: "iris_classifier:v1.2.0" - `bentoml containerize` command also supports the use of the `latest` tag + 'bentoml containerize' command also supports the use of the 'latest' tag which will automatically use the last built version of your Bento. You can provide a tag for the image built by Bento using the - `--tag` flag. Additionally, you can provide a `--push` flag, + '--docker-image-tag' flag. Additionally, you can provide a '--push' flag, which will push the built image to the Docker repository specified by the image tag. You can also prefixing the tag with a hostname for the repository you wish to push to. - e.g. `bentoml containerize IrisClassifier:latest --push --tag - repo-address.com:username/iris` would build a Docker image called - `username/iris:latest` and push that to docker repository at repo-address.com. + e.g. 'bentoml containerize IrisClassifier:latest --push --tag + repo-address.com:username/iris' would build a Docker image called + 'username/iris:latest' and push that to docker repository at repo-address.com. - By default, the `containerize` command will use the current credentials + By default, the 'containerize' command will use the current credentials provided by Docker daemon. - `bentoml containerize` also uses Docker Buildx as backend, in place for normal `docker build`. + 'bentoml containerize' also uses Docker Buildx as backend, in place for normal 'docker build'. By doing so, BentoML will leverage Docker Buildx features such as multi-node builds for cross-platform images, Full BuildKit capabilities with all of the - familiar UI from `docker build`. + familiar UI from 'docker build'. - We also pass all given args for `docker buildx` through `bentoml containerize` with ease. + We also pass all given args for 'docker buildx' through 'bentoml containerize' with ease. """ from bentoml._internal.utils import buildx @@ -268,7 +268,7 @@ def containerize( # type: ignore if platform and len(platform) > 1: if not push: logger.warning( - "Multiple `--platform` arguments were found. Make sure to also use `--push` to push images to a repository or generated images will not be saved. For more information, see https://docs.docker.com/engine/reference/commandline/buildx_build/#load." + "Multiple '--platform' arguments were found. Make sure to also use '--push' to push images to a repository or generated images will not be saved. For more information, see https://docs.docker.com/engine/reference/commandline/buildx_build/#load." ) if push: load = False