In another article I suggest installing Redis with docker but do not tell how. In this article I cover how to get a Redis Image up and running with Docker locally.
First you need to install Docker for your system. After you have Docker installed, next you need to download a Redis image. Here is a list of official redis images.
To get the image you can use the pull method.
To view all of the current images you have on your system type
docker image ls -a
You should see something like this if you have any redis downloaded.
Next create and run a new container with this command:
docker run --name redis-5 -dp 127.0.0.1:6379:6379 redis
–name is how you tell it the name you want for the container mine is redis-3
-dp the -d starts in detached mode, the p is for port and mine maps 6379 to 6379 127.0.0.1:6379:6379 tells docker to start the container with an ipv4 of 127.0.0.1 and network the systems port 6379 to the containers port 6379 without the ipv4 part Docker starts with an ipv4 of 0.0.0.0 127.0.0.1 is localhost some systems may map 0.0.0.0 to localhost in the hosts file too. You an add almost any conforming IP you want here and that will be the IP for the container docker run creates.
Here is a link to the docker docs about networking. Here is a link to Learning Ocean about docker networking.
redis is the name of the image I want to use to create the container.
That command will output something like this.
Notice in the image, I did not specify an IP so it starts with an ipv4 of 0.0.0.0 not very helpful.
Once you have created the container you can start and stop it with the docker stop and start commands.
You will need to install the redis-cli if you want to quickly test your redis docker container is working. I am using ubuntu so I just install the redis-tools package. If you are using something else you are in for a world of hurt, see this stack question. Ubuntu makes programming easier for most things.
Now to test if your docker redis is working just type the following into your command line to interact with redis via cli
You should see the following output, just the ip and port means your redis is working
To learn more about how to configure your symfony app to use this redis connection read this article.
Sometimes we make mistakes. When first learning docker we probably make many mistakes and end up with tons of unused docker images.
If you are on Linux like me, you won’t have a desktop dashboard like Mac and Windows get, so things are harder. To see a list of what images you have created you use the following command
docker ps -a
That command will output something like this.
It will show the CONTAINER ID, IMAGE, COMMAND etc. as you can see. To delete an image you use the container id with docker rm like this.
docker rm b5f8fae52bce
I’ve seen older internet posts using the IMAGE value but I had no success with that method. I am guessing something changed. I didn’t even see an example of this I just tried it. I don’t see any mention of this in the docs either. But it works. This part in the getting started intro actually explains it. I think something did change.
Containers are quickly and drastically changing the way we build and deploy apps these days. Containers make deployment easier and faster by providing the exact environment that your code needs to operate. However, with this power and ease comes complexity.
First off there are various container technologies, but the most common is Docker.
OpenShift vs Kubernetes: What are the Differences? Basically Openshift uses Kubernetes under the hood and offers improved features especially to security. One of the main reasons I never used Docker and Kubernetes was due to running all containers in root mode. That just begs to be hacked and destroyed. So when I realized that is how it worked I moved on. Now someone has done something about the lunacy.
The Following video explains containerization technology.
This video actually does a Virtual Machine vs Container comparison which is handy information to know. When I first started down the Microservices route I was using Virtual Machines to emulate environments. Now I can just use Docker. The VM ate tons of resources.
Introduction To Docker and Docker Containers
This next video is about Docker and containerization. It covers some of what was in the above video but explains Docker.
Docker Tutorial – What is Docker & Docker Containers, Images, etc?
I really like this video it does a nice job of explaining Docker with diagrams.
Docker Tutorial for Beginners – A Full DevOps Course on How to Run Applications in Containers
Once you know what Docker is you will want to know how to use it. This is a Two Hour tutorial course on Docker.
Container Orchestration Explained
What is Kubernetes
Once you learn about containers and Docker you then need to know how to orchestrate your applications Docker containers. Kubernetes is an orchestrator for containers.
Kubernetes for Beginners – Docker Introduction in 15 Minutes
This video explains more about containerization, docker, kubernetes and why you would want to use them.
What is OpenShift?
Once you decide you want to use Kubernetes you need some way to host your apps. Meet OpenShift
OpenShift Technical Overview
Building and running micro services on OpenShift: Part I
This video has some useful technical information about how OpenShift works.
Building and running micro services on OpenShift: Part II
This video has some useful technical information about how OpenShift works with Kubernetes to orchestrate your application and help it scale up and down in response to traffic.
Building and running Microservices on OpenShift: Part III
This video further covers some of the basic features of OpenShift from a developers standpoint.
Demo – Deploying from GitLab to OpenShift Container Cluster