简体   繁体   English

从“Docker quickstart终端”启动docker时如何添加`--registry-mirror`?

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

From the docker distribution document: https://github.com/docker/distribution 来自docker分发文档: https//github.com/docker/distribution

It says to configure the docker to use the mirror, we should: 它说配置docker使用镜像,我们应该:

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: 我是docker的新手,我通过提供的“Docker Quickstart Termial”应用程序从mac normal启动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

Is it the correct file that I can put my '--registry-mirror' config to it? 它是正确的文件,我可以把我的'--registry-mirror'配置给它吗? What should I do? 我该怎么办?

If you do a docker-machine create --help : 如果你做一个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) 但是,由于你的' default 'docker-machine可能已经存在(做一个docker-machine ls ),你可能需要先删除它( docker-machine rm default :确保你可以轻松地从你的本地Dockerfiles重新创建你的图像,以及/或者您没有需要先保存的数据容器)

Open C:\\Users\\<YourName>\\.docker\\daemon.json , edit the "registry-mirrors" entry in that file. 打开C:\\Users\\<YourName>\\.docker\\daemon.json ,编辑该文件中的“registry-mirrors”条目。

在此输入图像描述

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使Docker避免V1注册 - How to make Docker to avoid V1 registry 如何从Docker映像中排除应用程序设置(并将它们添加到容器中)? - How to exclude app settings from a docker image (and add them to the container)? 如何设置Docker存储库文件以从Ubuntu中提取Docker? - How do I setup a Docker repo file to pull Docker from in Ubuntu? Mac OS X和Docker 1.9.1不安全的注册表位置 - Mac OS X & Docker 1.9.1 Insecure registry location 调试docker化项目时如何默认不使用HTTPS(使用Docker作为主机而不是IIS Express)? - How to not use HTTPS by default when debugging a dockerized project (using Docker as host instead of IIS Express)? 如何启用实验性 Docker CLI 功能 - How to enable experimental Docker CLI features 如何将 kubernetes 配置传递给 docker 运行命令? - How to pass in kubernetes config into a docker run command? 如何修改opengauss的docker中数据库的配置 - How to modify the configuration of the database in docker of opengauss 如何将配置文件传递到 docker for windows - How to pass a config file into docker for windows 从官方 docker 镜像启动时,payara 完整应用服务器的管理控制台的默认用户名和密码是什么? - What is the default username and password for the administration console of the payara full app server when booted from the official docker image?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM