0Pricing
Docker & Kubernetes for Developers · บทเรียน

การเรียกใช้คอนเทนเนอร์แรกของคุณ

นำแอปพลิเคชันอย่างง่ายไปใช้งานโดยใช้อิมเมจ Docker ที่สร้างไว้ล่วงหน้า และโต้ตอบกับแอปพลิเคชันผ่านบรรทัดคำสั่ง

การเรียกใช้คอนเทนเนอร์แรกของคุณ เป็นบทเรียน Docker & Kubernetes for Developers ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Docker & Kubernetes for Developers และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Docker & Kubernetes for Developers มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Getting Started with Containers

Time to run real containers. You'll launch apps from images, interact with them, and learn the commands that manage their lifecycle.

Launching Containers with 'docker run'

docker run is your launch button: it checks for the image (pulling if needed), creates a container from it, and starts it — all in one command.

Your First Container: Hello World

Run the simplest container there is: hello-world. It prints a message and exits. Try it below.

docker run hello-world

What Just Happened?

Behind that hello-world run, Docker pulled the image, created a container, ran its command, printed the greeting, then stopped. A clean first cycle.

Interacting with Containers

To work inside a container, combine the -it flags: -i keeps STDIN open and -t gives you a terminal, so you can type commands inside it.

Get a Shell in Alpine Linux

Spin up minimal Alpine Linux and drop into its shell to run real Linux commands. Type exit to leave the container.

docker run -it alpine sh

Backgrounding with '-d'

To keep a container running without locking your terminal, use detached mode with the -d flag. Docker prints the container ID and hands control back.

Connecting with Port Mapping

Containers are isolated, so reach a service inside one with port mapping. The -p flag maps a host port to a container port: host:container.

Launching Nginx in Detached Mode

Combine detached mode and port mapping to run Nginx in the background, mapping your host's 8080 to the container's port 80. See the command below.

docker run -d -p 8080:80 nginx

Stopping & Removing Containers

Clean up when you're done: docker stop halts a running container and docker rm removes a stopped one. Grab the ID from docker ps first.

# First, find your Nginx container ID:
docker ps

# Then, stop it:
docker stop <your_nginx_container_id>

# Finally, remove it:
docker rm <your_nginx_container_id>

Quick Check: Interactive Mode

You want to run a container and immediately get a shell inside it to execute commands. Which option would you use with docker run?

Lesson Recap: Running Containers

Recap: docker run launches containers; -it gives a shell, -d runs detached, -p maps ports — plus stop and rm to clean up afterward.

คำถามที่พบบ่อย

บทเรียน “การเรียกใช้คอนเทนเนอร์แรกของคุณ” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การเรียกใช้คอนเทนเนอร์แรกของคุณ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Docker & Kubernetes for Developers ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Docker & Kubernetes for Developers มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การเรียกใช้คอนเทนเนอร์แรกของคุณ”

นำแอปพลิเคชันอย่างง่ายไปใช้งานโดยใช้อิมเมจ Docker ที่สร้างไว้ล่วงหน้า และโต้ตอบกับแอปพลิเคชันผ่านบรรทัดคำสั่ง คุณปฏิบัติ Docker & Kubernetes for Developers ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Docker & Kubernetes for Developers หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Docker & Kubernetes for Developers บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “การเรียกใช้คอนเทนเนอร์แรกของคุณ” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Docker & Kubernetes for Developers นี้ได้ไหม

ได้ บทเรียน Docker & Kubernetes for Developers ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. บทนำสู่การทำคอนเทนเนอร์
  2. การติดตั้ง Docker และคำสั่งพื้นฐาน
  3. การเรียกใช้คอนเทนเนอร์แรกของคุณ
  4. การจัดการอิมเมจและคอนเทนเนอร์ Docker
← กลับไปที่ Docker & Kubernetes for Developers