Using Rancher UI to manage docker containers


Blog / Project

Hello!

Without further ado lets dig into the world of containers! I’ll show how to easily run rabbitmq using rancher on docker 🙂

Plan for this post:

  1. What is docker? How to set it up?
  2. Basic commands helpfull using docker
  3. What is Rancher? How to set it up?
  4. Example with running rabbitmq using rancher
  5. Sum up

What is docker?

As we can read on the docker.com docker is software container platform that allows us to run our applications in isolated containers. The main goal of using containers is to unify the envioronment for apps and to eliminate „works on my machine”. In many cases it simplifies the process of developing, scaling and testing apps.

All you have to do if you want install docker is downloading install file from this site: DOCKER FOR WINDOWS or DOCKER FOR LINUX or DOCKER FOR MAC
A
nd run the installation. That’s it ! 🙂

Docker basic commands

Lets open the console and we can start!

docker version – shows the current version of docker

docker info – shows more specific informations and settings about running docker instances, containers

docker run IMAGE – runs image in container. In simple words it download the image (of an application), creates some isolated space for it called container and then install it there. Images could be found on docker hub or can be made by yourself.

docker run -d -p 80:80 nginx – means hey docker run nginx in detached mode and map the internal container port 80 with external 80 so it could be seen outside. After running it we can go to browser and type: „localhost:80” or „ip_addr:80” and the nginx start page should appear.

docker ps – list all running containers. Adding -a option will show all containers even stoped ones.

docker stop name(or container id) – stops running container

docker rm name(or container id) – removes container

What is Rancher?

Rancher gives us UI to manage containers, hosts, statuses and much more. Can help us start with docker. I’ll show you how to quick set it up and deploy some containers.

To install Rancher you will need to type:


docker run -d --restart=unless-stopped -p 8080:8080 rancher/server

Then you can check it with:

docker ps

docker logs -f CONTAINER_ID

Then just go to localhost:8080 in your browser and voila:

First thing that we can do after install rancher server is to change Host Registration URL in ADMIN/SETTINGS tab or just localhost:8080/admin/settings. It is obligatory if we want to run rancher server and hosts on the same machine. So the goal is to change localhost to our ip addr:8080 (to check it just run ipconfig in cmd).

Then we can go to INFRASTRUCTURE/HOSTS tab and click Add Host. We’ve got few options of host providers for local one choose Custom. Then in point 4.type your ip addr the same that you set in Admin tab. Then just copy generated command (with or without sudo) and run it in your cmd.

Check if it’s run by docker ps and additionally you can check containers logs by typing docker logs -f CONTAINER_ID.

Finally you can go to INFRASTRUCTURE/HOSTS tab and you should see youd host setting up and running the basic set of containers.

Set up RabbitMQ

We could find rabbitmq on https://hub.docker.com/_/rabbitmq/ and see what kind of images it provides. I’ll choose rabbitmq:3-management with management panel available at internal port 15672.

  1. Go to STACKS/USER tab and click Add Stack
  2. Define name for ex. RabbitMq and click Create
  3. Now we are inside the stack and can add some services.
  4. Click Add service
  5. In this case we’re only interested in minimal configuration. We have to define Name for this service, Select Image – which name has to be exacly the same as on docker hub. And the last thing it’s to add port map 15672 > 15672. So the internal port of management panel will be accessible by localhost.
  6. Then you will see your container running:
  7. Click on port and you will be redirected to Rabbitmq management panel.

Sum up

Rancher is a great tool that can help you with containers management: deploy, scale and monitor is easy as one click. Of course it’s worth to know how docker exacly works, but that topic we will cover in the next post 🙂

And subscribe to my RSS feed!
follow us in feedly

Regards!
Jacob