Hello all, I understand that `bentoml build --con...
# ask-for-help
d
Hello all, I understand that
bentoml build --containerize
is a combination of
bentoml build
and
bentoml containerize
So I was expecting to use all the options for bentoml containerize commands like (--platform, -t) following
bentoml build --containerize
, but apparently that's not supported? Please let me know if there is a way to do this!
m
Yep I experienced the same issue with --platform and thus split the command in two, why do you need it in a single command?
my build command looks like
Copy code
bentoml build --version $(TAG) && \
bentoml containerize --opt platform=linux/amd64 ${MODEL_NAME}:${TAG}
d
Yeah, no need for a single command 🙂 I was wondering if there is an option that I didn't find 🙂
Can I run docker build command after bentoml build instead of using bentoml containerize?
Can I run
docker build
command after
bentoml build
instead of using
bentoml containerize
? I'm asking this because in my gitlab ci.yml script, I need to build bentoml first under a python image, and I need to perform containerization + docker push under a docker image. They are two different stages. If I can only perform containerization (docker build) using
bentoml containerize
command, I can't separate these into two stages which use independent images. Instead I need to download python under the docker image, which is not ideal.
j
One solution that you can do is to use a custom Dockerfile template that extends our base template. https://docs.bentoml.com/en/v1.1.11/guides/containerization.html we will soon update this in our 1.2 documentation too!
👀 1
@Jiang
d
@Jian Shen Yap Thank you for the answer. Let me make sure I understood this correctly. By using the custom Dockerfile, I can only add stuff that I want to run during
bentoml containerize
, which doesn't change the fact that this command is still require both "Python" and "Docker" image to run in a cloud build. So my pain point is that, my gcp cloud build script can have one image at a time, but this
bentoml containerize
requires docker image in the background when bentoml itself requires a python image. So it needs two images at the same time. Please let me know if there is a way to dissect the bentoml containerize command so that I can run docker build command separately. Or is there a different way that I can resolve this issue? Please let me know!
j
Hey David, I don't think I am understanding the challenges correctly. Docker Images works in layer where they are composable, what do you mean that you need 2 images for a Bento Deployment?
d
@Jian Shen Yap I might be misunderstanding something here as well. Do you guys have any example of google cloud build script that works with bentoml build and bentoml containerize? Here is my brief example
Copy code
steps:
  - name: "gcr.io/cloud-builders/docker"
    args:
      [
        "run",
        "--rm",
        "-v",
        "/workspace:/workspace",
        "python:3.11",
        "bash",
        "-c",
        "cd /workspace && pip install -r requirements.txt && pip install -e . && bentoml build && bentoml containerize $SERVICE_NAME:latest --platform linux/amd64 -t gcr.io/$PROJECT_ID/$REGISTRY_NAME:$TAG_NAME",
      ]
And I'm facing issues when I'm running
bentoml containerize
I'm getting the following error.
Copy code
Step #0: WARNING: Docker not found. Make sure it is installed and in your PATH. See <https://docs.docker.com/get-docker/>
Step #0: WARNING: Docker not found. Make sure it is installed and in your PATH. See <https://docs.docker.com/get-docker/>
Step #0: Error: [bentoml-cli] `containerize` failed: Backend docker is not healthy.
This is because bentoml build is looking for docker that might need some changes to point to
"<http://gcr.io/cloud-builders/docker|gcr.io/cloud-builders/docker>"
. Do you see the challenges here? I'm not sure if there are some params that I could use with
bentoml containerize
to fix this issue.
j
I see that you are using cloud build. The reason that you get this is because
Copy code
Step #0: Error: [bentoml-cli] `containerize` failed: Backend docker is not healthy.
there is no docker daemon inside a container already. For cases like this, you can either use a
dind
(docker in docker) image, OR using the
dockerfile
that is generated by
bentoml build
in your Cloud Build. I would suggest the latter. You can access the Bento built by
bentoml build
by doing
bentoml get <bentoml tag> -o path
. inside you should be able to find a generated
Dockerfile
that is being used by the
bentoml containerize
command!
❤️ 1
d
Thank you so much. I will take a look.