Install Docker on a Mac

Download Docker.dmg from this link, then install it. Or, you can also use brew to install.

brew cask install docker

Install Docker on CentOS

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo
sudo yum install -y docker-ce docker-ce-cli
# If you want to install a specific version:
# Show the available versions
# yum list docker-ce --showduplicates | sort -r
# yum install -y docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING>
sudo systemctl start docker

Docker Registry in China

Update registry-mirrors

Update in /etc/docker/daemon.json

  "registry-mirrors": [

Setup and Deploy Docker Registry Server

docker run \
  --name registry \
  --restart always \
  -p 5000:5000 \
  -v $(pwd)/data:/var/lib/registry -d registry:2

Tool: Harbor


Remove Images from Docker Regsitry

docker run --rm anoxis/registry-cli -r --delete-all --no-validate-ssl
docker exec registry bin/registry garbage-collect /etc/docker/registry/config.yml

Tools: Dive

Dive: A tool for exploring each layer in a docker image

Trick using Docker

  • Get Env

    docker exec container bash -c 'echo "$ENV_VAR"'

  • Get Container IP Address

    docker inspect --format '{{ .NetworkSettings.IPAddress }}' container_name_or_id
    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

Docker Images