Running Your First Container
Deploy a simple application using a pre-built Docker image and interact with it via the command line.
Running Your First Container is a free Docker & Kubernetes for Developers lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Docker & Kubernetes for Developers learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
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-worldWhat 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 shBackgrounding 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 nginxStopping & 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.
Frequently asked questions
Is the “Running Your First Container” lesson free?
Yes — the full text of “Running Your First Container” is free to read here on the web, and the Docker & Kubernetes for Developers course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Docker & Kubernetes for Developers course, upgrade to CoddyKit PRO.
What will I learn in “Running Your First Container”?
Deploy a simple application using a pre-built Docker image and interact with it via the command line. You practise Docker & Kubernetes for Developers with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Docker & Kubernetes for Developers?
No prior experience is required. Docker & Kubernetes for Developers on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Running Your First Container” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Docker & Kubernetes for Developers lesson?
Yes. Every Docker & Kubernetes for Developers lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Introduction to Containerization
- Installing Docker & Basic Commands
- Running Your First Container
- Managing Docker Images and Containers