我一直在使用下面的Vagrantfile创建虚拟机,同时通过简单地运行流浪程序在vm上安装docker。
现在,每当我尝试创建虚拟机并安装docker时,这个脚本都会失败。
# -*- mode: ruby -*-
# vi: set ft=ruby :
boxes = [
{
:name => "manager1",
:eth1 => "192.168.205.10",
:mem => "512",
:cpu => "1"
},
{
:name => "manager2",
:eth1 => "192.168.205.11",
:mem => "512",
:cpu => "2"
},
{
:name => "manager3",
:eth1 => "192.168.205.12",
:mem => "512",
:cpu => "2"
},
{
:name => "worker1",
:eth1 => "192.168.205.13",
:mem => "1024",
:cpu => "2"
},
{
:name => "worker2",
:eth1 => "192.168.205.14",
:mem => "1024",
:cpu => "2"
},
{
:name => "worker3",
:eth1 => "192.168.205.15",
:mem => "1024",
:cpu => "2"
}
]
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.boot_timeout = 2000
config.vm.provider "vmware_fusion" do |v, override|
override.vm.box = "base"
end
# Turn off shared folders
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
boxes.each do |opts|
config.vm.define opts[:name] do |config|
config.vm.hostname = opts[:name]
config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = opts[:mem]
v.vmx["numvcpus"] = opts[:cpu]
end
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--name", opts[:name]]
v.customize ["modifyvm", :id, "--memory", opts[:mem]]
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
end
config.vm.network :private_network, ip: opts[:eth1]
end
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get -y upgrade
apt-get -y install
apt-transport-https
ca-certificates
curl
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get -y install docker-ce docker-ce-cli containerd.io
getent group docker || groupadd docker
usermod -aG docker vagrant
service docker restart
SHELL
end
end
我一直有这个错误
manager1: E
manager1: :
manager1: Failed to fetch https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/containerd.io_1.6.8-1_amd64.deb Hash Sum mismatch
manager1:
manager1: Hashes of expected file:
manager1:
manager1: - SHA512:6eb0014637ad22d560eba5178b5d5cc54cdcc9ed3b272aebee3985f96738f1e7d40ed69894619b151255683489c22fd9ea70b162ace56798e298d9a0d8da67e2
manager1:
manager1: - SHA256:46f1029a59484e58f21ecc45ae58bbe90620e1616d73048aaa61169f9ef957af
manager1: - SHA1:7a18fb24a5cd293cdd0f2f7e1c2ffd2703f2e035 [weak]
manager1: - MD5Sum:85967f85ea77756f14fc57523a7c29d0 [weak]
manager1: - Filesize:28140650 [weak]
manager1: Hashes of received file:
manager1: - SHA512:d9ba9dc20038dc0310d3d61bdc55fca7ce7123caf1f1f4dde8a06ea47ec917cb64a94d49b9cf5dd918058a1a41dc501a8953b8aa2a2401b2a00329b9cd0d1b99
manager1: - SHA256:689afaad3eef20f553ffe1191e2fa0e7946da274968f3811d2cb21b50e73002c
manager1: - SHA1:f529a30f513ac3f896ad9d0f63a6e6e050095071 [weak]
manager1: - MD5Sum:43891c37db034c6a084ea04abb463f5a [weak]
manager1: - Filesize:28140650 [weak]
manager1: Last modification reported: Thu, 08 Sep 2022 20:43:28 +0000
manager1: E: Failed to fetch https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.18~3-0~ubuntu-focal_amd64.deb Hash Sum mismatch
manager1: Hashes of expected file:
manager1: - SHA512:be66b6bef0f9a64ba6669b2360882db0f5ed5f5d32f6a4bf0421b49e7dd7432cedd44e26d74dffa13f30ec3f70d4db96350f8411c6ee2523f7195848e7baeac2
manager1: - SHA256:995152b8e8ad73cff59ad2756c82ea40ab5634b862bcca1037ee945a811b99cf
manager1: - SHA1:be8ffe23e1f5ac53b559784376cea29e748a2998 [weak]
manager1: - MD5Sum:b0431ee9f86ad0d415d153a6ece57145 [weak]
manager1: - Filesize:41490986 [weak]
manager1: Hashes of received file:
manager1: - SHA512:1ecbac81e9eb947fe04fe9f61614af476e1a4893c4a31283af7e4c8ba89afe45bf27598a6cf36703cbd43cfe774748ec09b23baf0f78eebb6f9f70e4e42c82f7
manager1: - SHA256:037606a8f7a734f743759d1d5c36f3e81c1bd7e7409d38e5322cddf3a20f9621
manager1: - SHA1:be8ffe23e1f5ac53b559784376cea29e748a2998 [weak]
manager1: - MD5Sum:b0431ee9f86ad0d415d153a6ece57145 [weak]
manager1: - Filesize:41490986 [weak]
manager1: Last modification reported: Fri, 09 Sep 2022 09:01:03 +0000
manager1: E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
manager1: Failed to restart docker.service: Unit docker.service not found.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
我已经在下面修改了流浪者文件
# -*- mode: ruby -*-
# vi: set ft=ruby :
boxes = [
{
:name => "manager1",
:eth1 => "192.168.205.10",
:mem => "512",
:cpu => "1"
},
{
:name => "manager2",
:eth1 => "192.168.205.11",
:mem => "512",
:cpu => "2"
},
{
:name => "manager3",
:eth1 => "192.168.205.12",
:mem => "512",
:cpu => "2"
},
{
:name => "worker1",
:eth1 => "192.168.205.13",
:mem => "1024",
:cpu => "2"
},
{
:name => "worker2",
:eth1 => "192.168.205.14",
:mem => "1024",
:cpu => "2"
},
{
:name => "worker3",
:eth1 => "192.168.205.15",
:mem => "1024",
:cpu => "2"
}
]
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/focal64"
config.vm.boot_timeout = 2000
config.vm.provider "vmware_fusion" do |v, override|
override.vm.box = "base"
end
# Turn off shared folders
config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
boxes.each do |opts|
config.vm.define opts[:name] do |config|
config.vm.hostname = opts[:name]
config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = opts[:mem]
v.vmx["numvcpus"] = opts[:cpu]
end
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--name", opts[:name]]
v.customize ["modifyvm", :id, "--memory", opts[:mem]]
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
end
config.vm.network :private_network, ip: opts[:eth1]
end
config.vm.provision "shell", inline: <<-SHELL
apt-get clean
apt-get update
apt-get -y upgrade
apt-get -y install
apt-transport-https
ca-certificates
curl
gnupg-agent
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" > /etc/apt/sources.list.d/docker.list
apt-get clean
apt-get update
curl -k -O -L https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-scan-plugin_0.17.0~ubuntu-focal_amd64.deb
curl -k -O -L https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-rootless-extras_20.10.18~3-0~ubuntu-focal_amd64.deb
curl -k -O -L https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/containerd.io_1.6.8-1_amd64.deb
curl -k -O -L https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.18~3-0~ubuntu-focal_amd64.deb
curl -k -O -L https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce_20.10.18~3-0~ubuntu-focal_amd64.deb
sudo apt install ./docker-scan-plugin_0.17.0~ubuntu-focal_amd64.deb
sudo apt install ./docker-ce-rootless-extras_20.10.18~3-0~ubuntu-focal_amd64.deb
sudo apt install ./containerd.io_1.6.8-1_amd64.deb
sudo apt install ./docker-ce-cli_20.10.18~3-0~ubuntu-focal_amd64.deb
sudo apt install ./docker-ce_20.10.18~3-0~ubuntu-focal_amd64.deb
getent group docker || groupadd docker
usermod -aG docker vagrant
service docker restart
SHELL
end
end
然而,在安装进度显示消息的不同位置,我仍然有这样的错误
manager1: Get:1 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-scan-plugin amd64 0.17.0~ubuntu-focal [3521 kB]
manager1: dpkg-preconfigure: unable to re-open stdin: No such file or directory
..........................................................................
..........................................................................
..........................................................................
..........................................................................
manager1: Unpacking docker-scan-plugin (0.17.0~ubuntu-focal) ...
manager1: Setting up docker-scan-plugin (0.17.0~ubuntu-focal) ...
manager1: WARNING:
manager1: apt
manager1:
manager1: does not have a stable CLI interface.
manager1: Use with caution in scripts.
..........................................................................
..........................................................................
..........................................................................
manager1: - Filesize:8392456 [weak]
manager1: Last modification reported: Fri, 09 Sep 2022 09:01:04 +0000
manager1: Fetched 8392 kB in 14s (592 kB/s)
manager1: E
manager1: :
manager1: Failed to fetch https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-rootless-extras_20.10.18~3-0~ubuntu-focal_amd64.deb Hash Sum mismatch
manager1:
manager1: Hashes of expected file:
manager1: - SHA512:a157e61be464612c83b5739792beec6bbf4ecffe581d26be30c1abbdf78f325569abea87ad2d7a1ed1ec0a7df3dd1c5209b6998368730d4de03b1ba9429dffa0
manager1: - SHA256:e7e3f7d874ef3b6a81a2bb453b013a8b902f44020cf98fb903f79643125da0e2
manager1: - SHA1:b6baad11031fbb46f452b26acd50b919409f66da [weak]
manager1: - MD5Sum:9e4d78d39526a215879bea52b869c65c [weak]
manager1: - Filesize:8392456 [weak]
manager1: Hashes of received file:
manager1: - SHA512:a157e61be464612c83b5739792beec6bbf4ecffe581d26be30c1abbdf78f325569abea87ad2d7a1ed1ec0a7df3dd1c5209b6998368730d4de03b1ba9429dffa0
manager1: - SHA256:abcaa85388bc4f8416101cf4141c1f5f262798206f12ac66501a4f75c16a7d6b
manager1: - SHA1:b6baad11031fbb46f452b26acd50b919409f66da [weak]
manager1: - MD5Sum:9e4d78d39526a215879bea52b869c65c [weak]
manager1: - Filesize:8392456 [weak]
manager1: Last modification reported: Fri, 09 Sep 2022 09:01:04 +0000
manager1: E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
manager1: WARNING:
manager1: apt
manager1:
manager1: does not have a stable CLI interface.
manager1: Use with caution in scripts.
manager1: Reading package lists...
manager1: E
manager1: :
manager1: Invalid archive member header
manager1: E
manager1: :
manager1: Could not read meta data from /home/vagrant/containerd.io_1.6.8-1_amd64.deb
manager1: E
manager1: : The package lists or status file could not be parsed or opened.
manager1: WARNING:
manager1: apt
manager1:
manager1: does not have a stable CLI interface.
manager1: Use with caution in scripts.
......................................................
.....................................................
....................................................
manager1: - SHA1:ad6d369560655b309a9108bc218e49ae54dfa90c [weak]
manager1: - MD5Sum:b0431ee9f86ad0d415d153a6ece57145 [weak]
manager1: - Filesize:41490986 [weak]
manager1: Last modification reported: Fri, 09 Sep 2022 09:01:03 +0000
manager1: Fetched 41.5 MB in 56s (742 kB/s)
manager1: E
manager1: :
manager1: Failed to fetch https://download.docker.com/linux/ubuntu/dists/focal/pool/stable/amd64/docker-ce-cli_20.10.18~3-0~ubuntu-focal_amd64.deb Hash Sum mismatch
manager1:
manager1: Hashes of expected file:
manager1:
manager1: - SHA512:be66b6bef0f9a64ba6669b2360882db0f5ed5f5d32f6a4bf0421b49e7dd7432cedd44e26d74dffa13f30ec3f70d4db96350f8411c6ee2523f7195848e7baeac2
manager1:
manager1: - SHA256:995152b8e8ad73cff59ad2756c82ea40ab5634b862bcca1037ee945a811b99cf
manager1:
manager1: - SHA1:be8ffe23e1f5ac53b559784376cea29e748a2998 [weak]
manager1:
manager1: - MD5Sum:b0431ee9f86ad0d415d153a6ece57145 [weak]
manager1:
manager1: - Filesize:41490986 [weak]
manager1:
manager1: Hashes of received file:
manager1:
manager1: - SHA512:d1c450b1bc78c44e2da788129b3bf4812811b40c176fe7069f7ec2928d29aee8027a758266e360e1c232846902379b7516cb8dde6ce721d2f07b15e642461f84
manager1:
manager1: - SHA256:be60933dfbca1778c175423cad6efcf018532ec515705fef105c1c0ee7b2c3da
manager1:
manager1: - SHA1:ad6d369560655b309a9108bc218e49ae54dfa90c [weak]
manager1:
manager1: - MD5Sum:b0431ee9f86ad0d415d153a6ece57145 [weak]
manager1:
manager1: - Filesize:41490986 [weak]
manager1:
manager1: Last modification reported: Fri, 09 Sep 2022 09:01:03 +0000
manager1: E
manager1: :
manager1: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
manager1: WARNING:
manager1: apt
manager1:
manager1: does not have a stable CLI interface.
manager1: Use with caution in scripts.
...............................
..............................
manager1: Do you want to continue? [Y/n] Abort.
manager1: Failed to restart docker.service: Unit docker.service not found.
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
请帮助我创建vm并安装docker。
在您的配置脚本中放入以下内容:
export DEBIAN_FRONTEND=非交互式
在接到任何合适的电话之前。
另请参阅:https://serverfault.com/questions/500764/dpkg-reconfigure-unable-to-re-open-stdin-no-file-or-directory?newreg=ab3bcf217d7e4a42bbbd82c3ce852392