Question: How to monitor a running docker container performance metrics. For example, CPU,memory, I/O and network stats? The docker stats command can continuously report the basic CPU, memory, network and disk I/O metrics. For example: # docker stats a3f78cb32a8e CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS […]
Docker
Docker Basics – Expose ports, port binding and docker link
This post illustrates three methods to link Docker containers. Expose ports and port binding Expose ports This method is used for within the same network or the docker host. Containers on the same network can talk to each other over their exposed ports and you can expose the ports by one of the below methods. […]
How to add new host entry in /etc/hosts when a docker container is run
This post shows how to add host-entries onto /etc/hosts on docker container when it is run. For the purpose of this post, we are using CentOS/RHEL 7 host. But this should work on any Linux host capable of running latest docker versions. Generally speaking, /etc/hosts file can not be modified before running the docker container. […]
How to Access Docker Container’s Network Namespace from Host
This post is to illustrate how to access the docker container’s network namespace. 1. Identify the docker container id you want to access and run below command as root on host. # docker ps 2. Get docker container’s PID: # pid=$(docker inspect -f ‘{{.State.Pid}}’ ${container_id}) 3. Create netns directory: # mkdir -p /var/run/netns/ 4. Create […]
How To Change The Time Zone For A Docker Container
The goal of this post is to set up the timezone on the container to match the same timezone on the Docker server, this will allow users to see the same time in both instances (Docker Server and Container). Most of the time Containers do not use the same time as the Docker server, this […]
“docker dead but subsys locked” – error while starting docker
The Problem The docker engine package was upgraded. After that the user is not able to start the docker service, and revert back with error “docker dead but subsys locked” on verifying the status of the service. Under normal circumstances, the general solution would be to remove the lock file and the dead files of […]
How to check the status and space used by images and containers
This post objective is to find out the stats of running container, system information related to space used by images and containers on /var/lib/docker. 1. ‘docker stats‘ command used to check the containers stats on system like CPU usage, IO usage, Memory usage. Below example is for 2 running containers dockerweb and webserver2. # docker […]
How to backup and restore Docker containers
The post outlines the steps to take the backup (snapshot) of docker Container and restore it. Please note that this post mainly discusses committing a container as an image. This works on the container that does not use data volume. For containers with data volume, backup of the data volume must be taken separately. Taking […]
Run Docker as a non-root user
The Docker containers by default run with the root privilege and so does the application that runs inside the container. This is another major concern from the security perspective because hackers can gain root access to the Docker host by hacking the application running inside the container. Method 1 – Add user to Docker group […]
How to Configure Btrfs as the Storage Engine in Docker
Docker is an open platform management tool for Linux Containers. It provides a means for developers and system administrators to build and package applications into lightweight containers. Docker uses devicemapper devices as the default storage engine. To use Btrfs as the storage engine, perform the following steps. Note that Red Hat Enterprise Linux (RHEL) removes […]