Den Container lokal ausführen und testen
Bauen und starten Sie den Container und sprechen Sie den Endpunkt von Ihrem Rechner aus an.
Den Container lokal ausführen und testen ist eine kostenlose MLOps Academy-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des MLOps Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der MLOps Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
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-apiMap 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-apiRun 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-apiList Running Containers
See what is up with docker ps. It shows each container ID, its image, status, and the ports it has mapped.
docker psHit 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/healthSend 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/bashStop 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. 🐳
Häufig gestellte Fragen
Ist die Lektion „Den Container lokal ausführen und testen“ kostenlos?
Ja — der vollständige Text von „Den Container lokal ausführen und testen“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des MLOps Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der MLOps Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Den Container lokal ausführen und testen“?
Bauen und starten Sie den Container und sprechen Sie den Endpunkt von Ihrem Rechner aus an. Du übst MLOps Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um MLOps Academy zu starten?
Keine Vorkenntnisse erforderlich. MLOps Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Den Container lokal ausführen und testen“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser MLOps Academy-Lektion Code schreiben und ausführen?
Ja. Jede MLOps Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Eine Dockerfile für eine Model-API schreiben
- Images mit Multi-Stage-Builds verkleinern
- Konfiguration über Umgebungsvariablen übergeben
- Den Container lokal ausführen und testen