2015-12-14 126 views
2

從泊塢窗分發資料:https://github.com/docker/distribution如何在從「Docker quickstart終端」啓動docker時添加`--registry-mirror`?

它說配置泊塢窗使用的鏡子,我們應該:

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 

我新手泊塢窗,我開始從碼頭工人正常的MAC由提供「泊塢窗快速入門Termial」應用程序,它actaully調用start.sh殼:

#!/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 

它是正確的文件,我可以把我的「--registry鏡」的配置呢?我該怎麼辦?

回答

1

如果你做一個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 

所以,你可以修改你的腳本中加入一個參數:

--engine-registry-mirror=... 

然而,由於你的「default」泊塢窗機很可能已經存在(做一個docker-machine ls),你可能需要先刪除它(docker-machine rm default:確保你可以很容易地從你的本地Dockerfiles重新創建你的圖片,和/或你沒有需要先保存的數據容器)

0

打開C:\Users\<YourName>\.docker\daemon.json,編輯該文件中的「registry-mirrors」條目。

enter image description here

{"registry-mirrors":["https://registry.docker-cn.com"],"insecure-registries":[], "debug":true, "experimental": true}

相關問題