如何从“Docker quickstartterminal”启动docker时添加`–registry-mirror`?

从docker分发文件: https : //github.com/docker/distribution

它说configurationdocker使用镜像,我们应该:

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 

我是docker工人的新手,我通过提供的“Docker Quickstart Termial”应用程序从mac正常启动docker,它实际上调用了一个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 

这是正确的文件,我可以把我的' – 注册镜像'configuration吗? 我该怎么办?

如果你做一个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机可能已经存在(做一个docker-machine ls ),你可能需要先删除它( docker-machine rm default :确保你可以轻松地从你的本地Dockerfiles重新创build你的图像, /或者你没有需要先保存的数据容器)

打开C:\Users\<YourName>\.docker\daemon.json ,编辑该文件中的“registry-mirrors”条目。

在这里输入图像说明

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