1. Enable repo:subscription-manager repos --enable=rhel-7-server-extras-rpms

  2. Install the package: yum install docker

  3. Activate IP forward

vi /etc/sysctl.conf

net.ipv4.ip_forward = 1

Configure LVM thin pool

pvcreate /dev/sdb
vgcreate vgdocker /dev/sdb

vi /etc/sysconfig/docker-storage-setup



If docker has already been started before that remove the /var/lib/docker content

systemctl stop docker
rm -rf /var/lib/docker/*
systemctl start docker


To detach the tty without exiting the shell, use the escape sequence Ctrl-p + Ctrl-q

  • List running containers: docker ps
  • List all containers: docker ps -a
  • List images: docker images
  • Return low-level information on a container or image: docker inspect <container id> or docker inspect <image>
  • Lookup the running processes of a container: docker top <container id>
  • Fetch the logs of a container (only for the json-file and journald logging) : docker logs <container id>
  • Attach to a running container (docker exec -it /bin/bash if if docker attach fails): docker attach <container id>
  • Start a container: docker start <container id>
  • Stop a container: docker stop <container id>
  • Restart a container: docker restart <container id>
  • Run a command in a new container: docker run -i -t centos /bin/bash
  • Copy files/folders between a container and the local filesystem: docker cp 'aa602111a6b7':/etc/fstab .
  • Show docker disk usage: docker system df -v
  • Remove one or more containers: docker rm <container id>
  • Remove one or more images: docker rmi <image id>
  • Delete all containers: docker rm $(docker ps -a -q)
  • Delete all images: docker rmi $(docker images -q)
  • List unused volumes: docker volume ls -qf dangling=true
  • Removing orphaned Docker volumes: docker volume rm $(docker volume ls -qf dangling=true)
  • Find out logging type (Red Hat - journal & Docker - json): docker info |grep Logging
  • Committing changes to an image: docker commit <container id> image_name
  • Push image: docker push username/image_name
  • Display data and meta devices: lvs -a
  • Shows logs in real time: journalctl -fu docker.service
  • See what's inside a container: docker export <container id> | tar -t
  • Search after bash location: docker export <container id> | tar -t | egrep ^bin/bash
  • Determine what containers use the docker volume: docker ps -a --filter volume=3a5e60541e8d862b8910f572f40c960ed2cf560614dcd244500a0635c88e5a68

Private registry (from image)

docker pull registry
docker run -d -p 5000:5000 --restart=always --name registry registry

vi /etc/sysconfig/docker

OPTIONS='--selinux-enabled --insecure-registry <IP>:5000'

systemctl daemon-reload
systemctl restart docker

docker pull centos && docker tag centos <IP>:5000/centos
docker push <IP>:5000/centos
docker pull <IP>:5000/centos

Important files

  • Default configuration: /usr/share/container-storage-setup/container-storage-setup
  • Storage configuration file (automatically updated by docker-storage-setup command): /etc/sysconfig/docker-storage
  • Override the default configuration: /etc/sysconfig/docker-storage-setup
  • Docker daemon options: /lib/systemd/system/docker.service
  • Change the way the docker daemon will start ($OPTIONS from /lib/systemd/system/docker.service): /etc/sysconfig/docker