How to Run a Containerized App with Docker
One of the biggest challenges for implementing cloud native technologies is learning the fundamentals — especially when you need to fit your learning into a busy schedule.
In this series, we’ll break down core cloud native concepts, challenges, and best practices into short, manageable exercises and explainers, so you can learn five minutes at a time. These lessons assume a basic familiarity with the Linux command line and a Unix-like operating system — beyond that, you don’t need any special preparation to get started.
In our last lesson, we defined some core concepts in container networking and learned how to publish container ports, opening a container’s services to traffic from the outside world. This time, we’re going to bring together most of what we’ve learned so far to run a containerized web app with persistent volumes and published ports: in this case, a knowledge-sharing wiki platform.
Table of Contents
- What is a Container?
- Creating, Observing, and Deleting Containers
- Build Image from Dockerfile
- Using an Image Registry
- Volumes and Persistent Storage
- Container Networking and Opening Container Ports
- Running a Containerized App ←You are here
Bringing the pieces together
Wikipedia is built on an open source platform called Mediawiki, and an official Docker image for the application is maintained on Docker Hub. That means it should be easy to get our own wiki running quickly — in less than five minutes, even!
The default architecture for this deployment is very straightforward: a single container for the application, which can either write data to a volume all on its own — the default configuration — or work in tandem with a second container running a production-grade database — the option you would want to use if you were taking this wiki to production, pushing it live for real-world use.
In this lesson, we’re going to start with a single-container configuration — but we won’t stop there. Next time, we’ll also explore how to link containers for a more production-ready configuration.
But we’re getting ahead of ourselves. For now, let’s focus on getting our wiki up and running!
Exercise: A Wiki as a Containerized App
Let’s start by creating a new volume that will store the persistent data for our wiki:
docker volume create wiki-data
Now we’re going to run a Docker container based on the official Mediawiki image. We’ll call our new container
solo-wiki since it’s going to run in a single-container configuration. We’ll also publish a port so we can access the application on our host machine, and add our volume for persistent storage.
docker run --name solo-wiki -v wiki-data:/wiki-data -p 8000:80 -d mediawiki
Now when we visit localhost:8000 in our web browser, we should see a starting page for our wiki. But the app still needs to be set up. On the starting page, click “Complete the installation.”
To follow the rest of the tutorial, read the full post at the Mirantis blog.