When the docker packages are installed, the services and related docker0 network interface are enabled. In some cases, you may want to disable the docker service and the docker0 network interface as well. This post details how to disable Docker and the docker0 interface if it is not required or if the docker0 interface is conflicting with other network interfaces/routes. 1. Ensure the Docker service is stopped: # service docker stop # for CentOS/RHEL 6 # systemctl stop docker # … [Read more...] about How to Disable Docker Process and docker0 Interface on CentOS/RHEL
Docker
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. However, current docker has an option "--add-host" which adds host-entries onto /etc/hosts when the container is run. Below is the syntax to add host entry while … [Read more...] about How to add new host entry in /etc/hosts when a docker container is run
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 the name space softlink: # ln -sfT /proc/$pid/ns/net /var/run/netns/[container_id] 5. Run ip netns command to access this name … [Read more...] about How to Access Docker Container’s Network Namespace from Host
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 post will show how to configure this. This is how this looks like before making the changes. Container Time: # docker exec 15c0c99b5c65 date Wed Aug 23 15:40:24 UTC 2019 Docker Server Time: # date Wed … [Read more...] about How To Change The Time Zone For A Docker Container
“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 the service. This is not applicable in this condition. # rm /var/run/docker/execdriver/native/ # rm /var/lock/subsys/docker # docker info Cannot connect to the Docker daemon. Is … [Read more...] about “docker dead but subsys locked” – error while starting docker
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 stats dockerweb webserver2 CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS e33f00e0e3ce dockerweb … [Read more...] about How to check the status and space used by images and containers
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 backup of Docker Container 1. Commit the required container as an image # docker commit -p [container-id] backup01 sha256:89682d4xxxxxx Now a new image backup01 will … [Read more...] about How to backup and restore Docker containers
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 1. To run Docker as a non-root user, you have to add your user to the docker group. 2. Create a docker group if there isn't one: $ sudo groupadd docker 3. Add … [Read more...] about Run Docker as a non-root user
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 the Btrfs storage driver from their build of Docker, both on the Extra Packages for Enterprise Linux (EPEL) repository and the … [Read more...] about How to Configure Btrfs as the Storage Engine in Docker
How to create Docker Image from a Container and Dockerfile
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 consists of the following components: Docker Engine – A portable, lightweight runtime and packaging tool Docker Hub – A cloud service for sharing applications and automating workflows Docker is used to create image-based application containers. Image-based containers package an application with … [Read more...] about How to create Docker Image from a Container and Dockerfile