Docker Container is very popular and top most choice of developers. In this article, will show you how to deploy docker container in production with a use case.

If you’re a learner or beginner in docker world, want to know what is Docker? This article is best suite for you to know how docker container can used in production.

What is Docker?

Docker is an open source platform for developers and sysadmins to build, ship, and run distributed applications in just few seconds without provisioning any new underlying infrastructure.

Production Use Case

Let’s assumed you’re a developer or Sysadmin or a DevOps engineer and you’re using a legacy system to run your application called Redis, but one day your product manager told you to run Redis application with latest version in production.

Immediately you will think how to finish the task. While you consider any solution, one of your team member come with an Idea to use Redis as Docker Container.

Now you will curious to know how to run a container to deploy Redis application?

How to Run a Docker Container ?

Containers are started based on a Docker Image. These images contain everything required to launch the process; the host system doesn’t require any configuration or dependencies. You can find existing images at or by using the command docker search <name>.

You found latest release version of Redis image in docker hub, So let’s explore how to launch docker container?

Install Docker Client

To perform this task, you need a Docker client tool installed on host system. Docker CLI has a command called run which will start a container based on a Docker Image. The structure command is docker run <options> <image-name>.

By default, Docker will run a command in the foreground. To run in the background, the option -d has to specified.

docker run -d redis
docker run -d redis

By default, Docker will run the latest version available, but if you want any specific version, we could specify it as a tag, for example, version 3.2 would be docker run -d redis:3.2.

Identify running Container

Execute following command to identify the running container just before you launched. This command displays the container name, Container ID and Status to find out information about individual containers.

docker ps
docker ps

You can run a command docker inspect <container-id> to get more details about container information like IP address and configuration details.

Access Redis Application

Your Redis application launched, but you will surprised, how to access it? Don’t worry, you need to expose the port. By default, Redis runs on port 6379.

So let’s bind that port when container started using -p <host-port>:<container-port> option.

The best way to solve your problem of running Redis in the background, with a name of redisUATPort on port 6379 is using the following command.

docker run -d --name redisUATPort -p 6379:6379 redis
Docker Port Exposed

Usually, it maps the port on the local host to, which means all IP addresses, but if you want to specify a particular IP address, then you need to define the port mapping, for example, -p

docker run -d --name redisUATPort -p redis

You can use following commands to find the port details to access your Application.

docker port redisUATPort 6379
docker ps

Attach Volume to Redis as Container

Containers are stateless, it means your data stored in containerized application will remove. You need to mount docker host directory with container to save all data and logs.

Just use following command-.

docker run -d --name redisMount -v /lib/docker/data/redis:/data redis

This command will define any data which needs to be saved on the Docker Host, but not inside containers, should be stored in /lib/docker/data/redis.

Run Container application in Foreground

If you want to see how container application can access in foreground, just execute the following command to interact on terminal.

docker run -it redisUATPort
docker run -it redis

That’s all in this lab. You finished with your task and Redis application is ready to use. Just relax and get ready to share feedback with your Product manager to discuss future roadmap. Cheers!!