How To Manage Docker Container Services From Docker Host - Part 8
Docker Linux Tutorials

How To Manage Docker Container Services From Docker Host – Part 8

Well in our last tutorial we manage to setup apache server using a Docker file and we learn the possibility and scope of using Docker file in automating build and configuration a Docker images.

But, it is a bit difficult to manage Docker container services by attaching Docker every time when we need to manage Docker container services like stopping or starting apache. Also, we cannot remember ContainerID every time for access Docker services.

So we came up with creating system-wide configuration files to access and manage Docker containers with ease.

Just in case, if you did Miss Previous tutorials regarding Docker, You can read here:

Part 1: What Is Docker And Concept Of Containers With Virtualization?
Part 2: How To Install Docker On CentOS/RHEL 6/7? And Learn Docker HUB Registration
Part 3A: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 A
Part 3B: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 B
Part 4: Learn To Install, Run And Delete Applications Inside Docker Containers – Part 4
Part 5: Learn To Push Custom Build Docker Image On Docker HUB (Repository) 
Part 6: What Are Docker File Learns To Use Them? | Simple Demo

Prerequisite:

Apache ContainerPart 7

Scenario :

Host OS: CentOS 7 x86_64
Host IP: 192.168.1.188
RAM: 4GB memory,
Network Port: 1GB/s
HDD: 1000GB of disk space.


Let’s start

Step 1: Name Your Docker Container (something rememberable)

As described above To do several tasks it is little tidy to use remember container id every time so to fix this problem you may name you Docker container with a unique name(descriptive name) and use that name to hit any command.

Now you can use this descriptive name replacing containerID to run above-mentioned commands (start, stop, top, stats etc.).

Step 2: Creating File for Docker Container

On CentOS/RHEL 7 you can create a systemd configuration file and manage the container services normally as you do for local system services. For our example, we are creating systemd file for our Apache container created in Part 7. Let’s say, the name is docker-httpd.service Follow following commands

Now append the following lines to file docker-httpd.service:

Save and close using :wq!

Step 3: Check Your Work

After you finish editing the file we need to reload the service/daemon of systemd to reflect the changes we have done.

Now we can do our task on Docker Container using below commands

This was just a simple example on what you can do with a simple Docker

You May Like:

Part 1: What Is Docker And Concept Of Containers With Virtualization?
Part 2: How To Install Docker On CentOS/RHEL 6/7? And Learn Docker HUB Registration
Part 3A: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 A
Part 3B: Getting Familiar With Docker Commands Docker Terms: Docker – Part 3 B
Part 4: Learn To Install, Run And Delete Applications Inside Docker Containers – Part 4
Part 5: Learn To Push Custom Build Docker Image On Docker HUB (Repository) 
Part 6: What Are Docker File Learns To Use Them? | Simple Demo


Kapendra
Love to write technical stuff with personal experience as I am working as a Sr. Linux Admin. and every day is a learning day and Trust me being tech geek is really cool.
http://kapendra.com

Leave a Reply