How to add `–registry-mirror` when starting docker from “Docker quickstart terminal”?

From the docker distribution document: https://github.com/docker/distribution

It says to configure the docker to use the mirror, we should:

  • How to prevent “docker-machine create” to install/upgrade docker host, just add it
  • How to build and start containers on multiple docker machines
  • OSX terminal vs Docker CLI
  • Unicorn error adding listener
  • Lumen: PHPUnit give failure but testing passed in Gitlab CI Runner
  • Issue in setting --sysctl net.core parameter with docker container
  • Configuring the Docker daemon
    
    You will need to pass the --registry-mirror option to your Docker daemon on startup:
    
    docker --registry-mirror=https://<my-docker-mirror-host> daemon
    

    I’m newbie to docker, and I start docker from mac normal by the provided “Docker Quickstart Termial” app, which actaully invokes a start.sh shell:

    #!/bin/bash
    
    VM=default
    DOCKER_MACHINE=/usr/local/bin/docker-machine
    VBOXMANAGE=/Applications/VirtualBox.app/Contents/MacOS/VBoxManage
    
    BLUE='\033[0;34m'
    GREEN='\033[0;32m'
    NC='\033[0m'
    
    unset DYLD_LIBRARY_PATH
    unset LD_LIBRARY_PATH
    
    clear
    
    if [ ! -f $DOCKER_MACHINE ] || [ ! -f $VBOXMANAGE ]; then
      echo "Either VirtualBox or Docker Machine are not installed. Please re-run the Toolbox Installer and try again."
      exit 1
    fi
    
    $VBOXMANAGE showvminfo $VM &> /dev/null
    VM_EXISTS_CODE=$?
    
    if [ $VM_EXISTS_CODE -eq 1 ]; then
      echo "Creating Machine $VM..."
      $DOCKER_MACHINE rm -f $VM &> /dev/null
      rm -rf ~/.docker/machine/machines/$VM
      $DOCKER_MACHINE create -d virtualbox --virtualbox-memory 2048 --virtualbox-disk-size 204800 $VM
    else
      echo "Machine $VM already exists in VirtualBox."
    fi
    
    VM_STATUS=$($DOCKER_MACHINE status $VM)
    if [ "$VM_STATUS" != "Running" ]; then
      echo "Starting machine $VM..."
      $DOCKER_MACHINE start $VM
      yes | $DOCKER_MACHINE regenerate-certs $VM
    fi
    
    echo "Setting environment variables for machine $VM..."
    clear
    
    cat << EOF
    
    
                            ##         .
                      ## ## ##        ==
                   ## ## ## ## ##    ===
               /"""""""""""""""""\___/ ===
          ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
               \______ o           __/
                 \    \         __/
                  \____\_______/
    
    
    EOF
    echo -e "${BLUE}docker${NC} is configured to use the ${GREEN}$VM${NC} machine with IP ${GREEN}$($DOCKER_MACHINE ip $VM)${NC}"
    echo "For help getting started, check out the docs at https://docs.docker.com"
    echo
    
    eval $($DOCKER_MACHINE env $VM --shell=bash)
    
    USER_SHELL=$(dscl /Search -read /Users/$USER UserShell | awk '{print $2}' | head -n 1)
    if [[ $USER_SHELL == *"/bash"* ]] || [[ $USER_SHELL == *"/zsh"* ]] || [[ $USER_SHELL == *"/sh"* ]]; then
      $USER_SHELL --login
    else
      $USER_SHELL
    fi
    

    Is it the correct file that I can put my ‘–registry-mirror’ config to it? What should I do?

  • How do you do an ElasticBeanstalk deploy for multiple docker containers?
  • Connecting local cassandra cluster with docker container
  • How to specify username and password upon docker push?
  • docker-compose does not see volumes changes in docker-compose.yml
  • Unable to locate dependency 'class library project(s)'
  • Docker Data Volume Container - Can I share across swarm
  • One Solution collect form web for “How to add `–registry-mirror` when starting docker from “Docker quickstart terminal”?”

    If you do a docker-machine create --help:

    docker-machine create --help
    Usage: docker-machine create [OPTIONS] [arg...]
    
    Create a machine.
    
    Run 'docker-machine create --driver name' to include the create flags for that driver in the help text.
    
    Options:
    ...
       --engine-insecure-registry [--engine-insecure-registry option --engine-insecure-registry option]     Specify insecure registries to allow with the created en
    gine
       --engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option]           Specify registry mirrors to use
    

    So you can modify your script to add one more parameter:

    --engine-registry-mirror=...
    

    However, since your ‘default‘ docker-machine probably already exists (do a docker-machine ls), you might need to remove it first (docker-machine rm default: make sure you can easily recreate your images from your local Dockerfiles, and/or that you don’t have data container that would need to be saved first)

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.