我正在尝试通过docker远程API构建docker映像,并且卡住COPY
从主机到docker容器的文件和目录,这是我的情况:
我有一个带有以下命令的Dockerfile,我正在尝试通过远程API模拟其行为
# ...
FROM img:tag
WORKDIR /app
COPY . .
# ...
docker build
所做的是将原始目录(第一个.
)扩展到当前路径,并将目标目录(第二个.
)作为指向目录的相对路径。 WORKDIR
在容器内。现在,如果我尝试通过远程API执行相同的操作,则必须执行以下请求
# creates container and generates a ContainerId
POST /containers/create {"Image": "img:tag"}
# starts ContainerId
POST /containers/#{container_id}/start
# generates an ImageId
POST /commit?container=#{container_id}
# creates container from the created image and generates a ContainerId2
POST /containers/create {"Image": ImageId, "WorkingDir": "/app"}
# starts ContainerId2
POST /containers/#{container_id}/start
# generates an ImageId2 with WORKDIR as /app
POST /commit?container=#{container_id}
# creates container from the created image and generates a ContainerId3
POST /containers/create {"Image": ImageId2}
# starts ContainerId3
POST /containers/#{container_id}/start
# uploads a tar file to a "relative" path from WORKDIR
PUT /containers/#{container_id}/archive?path=. <TAR FILE>
一切正常,但最后一行无效,将tar文件添加到/
(根路径)而不是WORKDIR
中,如何使其将tar文件添加到相对路径到WORKDIR
?
谢谢。