当我将命令运行sudo bash ~/ol_code_hosting/fedora.sh ~/ol_code_hosting/all_packages.txt
到以下 bash shell 脚本时(我已通过 docker 终端中的此脚本运行 bash 命令):
#!/bin/bash
sudo service docker restart
docker rm -f container_fedora
docker image rm -f fedora:latest
sudo docker pull fedora
sudo docker run -itd --name container_fedora fedora:latest
sudo docker exec container_fedora /bin/sh -c '
#dnf install dnf
#dnf clean all
#dnf check-update
#dnf upgrade
echo "outside1"
tmpfile=$(mktemp)
echo "outside2"
while IFS= read -r package; do
echo "inside loop"
if dnf info "$package" >"$tmpfile"
then
echo "Processing $package"
cat "$tmpfile" >>fedora_log.txt
else
printf "No package info for $package"
printf "%s\n" "$package" >>packages_not_in_fedora.txt
fi
done <"$1"
rm -f "$tmpfile"
exit'
sudo docker cp container_fedora:/fedora_log.txt ./fedora_log.txt
收到的输出:
container_fedora
Untagged: fedora:latest
Untagged: fedora@sha256:2c5b21348e9b2a0b4c49bd5013be6d406be8594831aba21043393fcfba7252e0
Deleted: sha256:98ffdbffd20736862c8955419ef7db69849d715131717697007c3e51f22915a5
Deleted: sha256:811f92a7a340873e7fef337f3f3cab4f353f24ca0b303ed0f46b00917e262a7b
Using default tag: latest
latest: Pulling from library/fedora
e1deda52ffad: Pull complete
Digest: sha256:2c5b21348e9b2a0b4c49bd5013be6d406be8594831aba21043393fcfba7252e0
Status: Downloaded newer image for fedora:latest
docker.io/library/fedora:latest
9909e072f6fe41b2a8909b414f199ddeadaaa8a5daac70e3d0f765726e288302
outside1
/bin/sh: line 21: : No such file or directory
outside2
Error: No such container:path: container_fedora:/fedora_log.txt
我不知道每次都会显示这样的错误消息。有人可以帮忙吗。非常感谢!