Categories
Software Development

How to list all stopped and running Docker containers

I often need to do this but forget exactly how to do this. I don’t know if this has changed. I could swear it has changed.

You will probably find crap all over the internet telling you to use

docker ps

But that only lists running containers. Same story for

docker container ls

So how do you get docker to list all the damn containers?

docker ps -a
homer simpson meme
You got to strangle docker for the truth about containers
Categories
Software Development Web Development

How to install Redis with Docker for local testing

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.

docker image ls outpu
output of docker image ls -a

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.

output of docker run
docker run output

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

redis-cli

You should see the following output, just the ip and port means your redis is working

your redis is working if you see this

To learn more about how to configure your symfony app to use this redis connection read this article.

Links

Here is a nice article about how to remove old images and containers and clean docker up.

Remove multiple docker images at once. This is good for when you have a bunch of unused images. Use this command to view all images currently on your system

Learning Ocean Docker tutorials – some of the best information you can find on Docker



		
Categories
Software Development Web Development

How to remove unused or broken docker container images.

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.

Docker container rm documentation.

Docker rm documentation.

Categories
Resources Web Security

Docker resources

Links, resources and videos about Docker in specific.

Manage sensitive data with Docker secrets – information from the documentation about using docker secrets. Secrets are for managing things like database passwords and other passwords.

Introducing docker secrets management – an article explaining what Docker secretes management is and it’s value.

Categories
Resources Software Development

Container technology resources and information

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.

Articles and links

Link to the Openshift Startup program membership page.

Link to Kubernetes free ebook. What to know before adopting kubernetes .

This is a really good link to a page full of OpenShift resources, videos, articles etc.

Link to Official OpenShift platform youtube page.

Link to OpenShift Demos and Developer info video playlist on youtube. This has some videos about version 3 but they are still useful as an overview of how OpenShift works etc.

What are the New Features of OpenShift 4? This article covers the new features in OpenShift.

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.

CRI-O container engine runtime for kubernets

Containerization Explained

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