我试图在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.
答案 0 :(得分:2)
试图在特拉维斯试图解决任何问题时遇到同样的问题。我在/var/log/upstart/docker.log中注意到了这条错误消息:
ERRO [0054]中的错误容器85f99b93c5307fe8ec45ea4e743147869cc25a3e5dfb91b623dd6b3eede1da3b开始exec命令:不能运行在容器8f40f7b49658cc9661446f61492d36f02e371bd4a22ef2f892f258bb856ea7e6 exec命令85f99b93c5307fe8ec45ea4e743147869cc25a3e5dfb91b623dd6b3eede1da3b:[8]系统错误:权限被拒绝
经过一番挖掘,我能够通过在特权模式下运行docker容器来解决它(docker run --privileged)。希望它有所帮助。