gpt4 book ai didi

docker - TravisCI-Docker-Exec失败

转载 作者:行者123 更新时间:2023-12-02 18:56:35 25 4
gpt4 key购买 nike

我正在尝试在TravisCI中启动一个容器,然后对其添加一些docker exec。但这每次都会失败,并显示255个错误代码。

我不明白的是,该过程在本地运行良好。
然后,我用标准容器(ubuntu)updated my travisCI script to something very simple。同样的事情正在发生。

我只是拉一个图像,无休止地运行它,然后尝试对其执行一些exec。我使用container_id文件存储容器ID(该部分有效)。

这是我的代码:

$ docker pull ubuntu:latest
latest: Pulling from ubuntu
age you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Status: Downloaded newer image for ubuntu:latest

$ docker run -d ubuntu:latest sh -c "while true; do sleep 5; done" > container_id
The command "docker run -d ubuntu:latest sh -c "while true; do sleep 5; done" > container_id" exited with 0.

$ docker logs `cat container_id`
The command "docker logs `cat container_id`" exited with 0.

$ docker exec `cat container_id` sh -c "mkdir /repository"
The command "docker exec `cat container_id` sh -c "mkdir /repository"" exited with 255.

$ docker logs `cat container_id`
The command "docker logs `cat container_id`" exited with 0.

$ docker exec `cat container_id` sh -c "cd /repository ; git clone https://github.com/tdeheurles/homecores"
The command "docker exec `cat container_id` sh -c "cd /repository ; git clone https://github.com/tdeheurles/homecores"" exited with 255.

$ docker logs `cat container_id`
The command "docker logs `cat container_id`" exited with 0.

$ docker exec `cat container_id` sh -c "cd /repository/homecores ; ./test/test.sh"
The command "docker exec `cat container_id` sh -c "cd /repository/homecores ; ./test/test.sh"" exited with 255.

$ docker logs `cat container_id`
The command "docker logs `cat container_id`" exited with 0.
Done. Your build exited with 1.

最佳答案

255表示已发生错误。
在像mkdir /repository这样简单的内容上,它可能意味着docker exec sh session 中的用户ID不是root,也无权在/中创建文件夹。

通过添加中间体来检查:

docker exec `cat container_id` sh -c "id -a"

docker exec man page提到 -u--user=选项,因此您可以尝试:
docker exec -u root `cat container_id` sh -c "mkdir /repository"

从下面的讨论中,似乎该错误可能与缺少lxc驱动程序有关。

有什么可以帮助的(至少在 circleci上:请参见 their doc on docker exec )是
sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' hctest)" -- bash -c ls

关于docker - TravisCI-Docker-Exec失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32219897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com