0Pricing
MLOps Academy · Aula

Execute e teste o contêiner localmente

Compile, execute e acesse o endpoint a partir da sua máquina.

Execute e teste o contêiner localmente é uma aula grátis de MLOps Academy no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de MLOps Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de MLOps Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Run It Locally First

Before shipping, run the container on your own machine. Catching bugs locally is far cheaper than debugging them in the cloud.

Start the Container

Launch the image with docker run. Without port mapping it runs, but nothing on your host can reach the API inside.

docker run model-api

Map the Port

The -p flag maps a host port to the container port. Now localhost:8000 reaches the model API serving inside.

docker run -p 8000:8000 model-api

Run in the Background

Add -d to detach and run in the background. Your terminal stays free while the service keeps serving.

docker run -d -p 8000:8000 model-api

List Running Containers

See what is up with docker ps. It shows each container ID, its image, status, and the ports it has mapped.

docker ps

Hit the Health Check

Confirm the service is alive by calling its /health endpoint. A 200 response means it is ready to take predictions.

curl http://localhost:8000/health

Send a Prediction

POST a sample payload to /predict and read the result. This proves the model loads and responds end to end.

curl -X POST http://localhost:8000/predict -d '{"x": [1, 2, 3]}'

Read the Logs

When something looks off, check docker logs. The container prints startup errors and stack traces straight to its log stream.

docker logs <container_id>

Shell Inside

Open a shell in a running container with docker exec to inspect files or the environment from within.

docker exec -it <container_id> /bin/bash

Stop and Clean Up

Finish by stopping the container with docker stop. Add --rm at run time so it is removed automatically when it exits.

docker stop <container_id>

Test Before You Push

If it runs clean and answers correctly here, it will behave the same in the cloud. Local testing is your last safe gate.

Quick Check

Let us check how you reach the API from your host.

Recap

You ran the image, mapped the port, checked health, sent a prediction, read logs, and cleaned up. Your container is deploy-ready. 🐳

Perguntas Frequentes

A aula “Execute e teste o contêiner localmente” é grátis?

Sim — o texto completo de “Execute e teste o contêiner localmente” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de MLOps Academy, atualize para CoddyKit PRO. O curso de MLOps Academy inclui 4 aulas no total.

O que vou aprender em “Execute e teste o contêiner localmente”?

Compile, execute e acesse o endpoint a partir da sua máquina. Você pratica MLOps Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar MLOps Academy?

Nenhuma experiência prévia é necessária. MLOps Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Execute e teste o contêiner localmente”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de MLOps Academy?

Sim. Cada aula de MLOps Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Escreva um Dockerfile para uma API de modelo
  2. Reduza as imagens com compilações em vários estágios
  3. Passe a configuração por variáveis de ambiente
  4. Execute e teste o contêiner localmente
← Voltar para MLOps Academy