2015-12-14 80 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}

相关问题