docker compose,vagrant and insecure Repository

时间:2015-06-05 11:49:30

标签: docker vagrant docker-compose

我已设置docker-compose从自定义存储库中提取图像。

以下是yaml文件的外观

my_service:
  image: d-myrepo:5000/mycompany/my_service:latest
  ports:
    - "8079:8079"

现在如果我运行流浪汉,就会出现错误

==>默认值:文件" /code/build/docker-compose/out00-PYZ.pyz/docker.auth.auth",第46行,在expand_registry_url中 ==>默认值:docker.errors ==>默认:。 ==>默认值:DockerException ==>默认:: ==>默认值:未启用HTTPS端点无响应和不安全模式。 以下SSH命令以非零退出状态响应。 Vagrant认为这意味着命令失败了!

/usr/local/bin/docker-compose -f "/vagrant/docker-compose.yml" up -d

Stdout from the command:



Stderr from the command:

stdin: is not a tty
Creating vagrant_y2y_1...
Pulling image d-myrepo:5000/mycompany/my_service:latest...
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 31, in main
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 21, in sys_dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 27, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.docopt_command", line 24, in dispatch
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.command", line 59, in perform_command
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.cli.main", line 464, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.project", line 208, in up
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 214, in recreate_containers
  File "/code/build/docker-compose/out00-PYZ.pyz/compose.service", line 197, in create_container
  File "/code/build/docker-compose/out00-PYZ.pyz/docker.client", line 710, in pull
  File "/code/build/docker-compose/out00-PYZ.pyz/docker.auth.auth", line 67, in resolve_repository_name
  File "/code/build/docker-compose/out00-PYZ.pyz/docker.auth.auth", line 46, in expand_registry_url
docker.errors.DockerException: HTTPS endpoint unresponsive and insecure mode isn't enabled.

我在网上看到它,它与不安全的回购有关。

仅在我编辑文件

时才有效
/etc/default/docker

内容

DOCKER_OPTS="-r=true --insecure-registry d-myrepo:5000 ${DOCKER_OPTS}"

重新启动docker服务并手动拉取图像。即。

docker pull d-myrepo:5000/mycompany/my_service:latest

有没有办法避免这个错误?并且配置运行顺利?也许我错过了docker-composer.yml文件中的一个选项?

1 个答案:

答案 0 :(得分:3)

感谢您的feedack,实现此目的的最佳方法是以下列方式设置vagrant配置

  config.vm.provision :docker
  config.vm.provision :docker_compose
  config.vm.provision "shell", path: "provision.sh", privileged: false

,而shell脚本provision.sh将包含以下相关行。

sudo echo "DOCKER_OPTS=\"-r=true --insecure-registry my_repo:5000 \${DOCKER_OPTS}\"" | sudo tee /etc/default/docker
sudo  service docker restart
sudo /usr/local/bin/docker-compose -f /vagrant/docker-compose.yml up -d --allow-insecure-ssl