使用Dockerfile在700(drwx ------)目录中创建文件

问题描述 投票:0回答:2

我正在为我的码头工人文件使用gitlab-runner基本图像

FROM gitlab/gitlab-runner:alpine
WORKDIR /app

RUN touch /etc/gitlab-runner/config.toml   # it doesn't work because of drwx------ direcotry
RUN touch /etc/config.toml                 # it worked because etc is   drwxr-xr-x directory 

COPY . /app
...
...

ENTRYPOINT ["yarn"]
CMD ["run", "start"]

使用工具检查图像

permissions

创建图像时,我在etc/gitlab-runner directory中看不到config.toml文件

  1. 是否隐藏?
  2. 如何在etc / gitlab-runner目录下创建config.toml文件

还想知道certs文件夹的用途是什么?它包含什么?实际上,我想将config.toml文件安装到主机上,以便在销毁容器时始终能获得运行程序详细信息。

docker gitlab dockerfile gitlab-ci-runner alpine
2个回答
0
投票
实际上,我想将config.toml文件挂载到主机上,以便在销毁容器时始终可以同步运行程序详细信息。

根据此语句,我想您无需担心创建文件,因为您的意图是将文件从主机装载到容器。在Linux环境上(在您的主机上)。在您的应用程序文件夹中创建一个文件夹,并将其保存为:

mkdir config touch config.toml

现在将您的docker文件更新为:

FROM gitlab/gitlab-runner:alpine WORKDIR /app COPY . . ... ... ENTRYPOINT ["yarn"] CMD ["run", "start"]

现在您重建图像并以以下方式启动容器:

docker build -t username/image_name . docker run -v "absolute path to the folder config":"/etc/gitlab-runner/" username/image_name

现在您应该会看到config.toml文件已安装到/ etc / gitlab-runner,并且容器运行也没有错误。

0
投票
gitlab/gitlab-runner映像declares a VOLUME for /etc/gitlab-runner,因此会忽略影响该目录的所有VOLUME命令。
© www.soinside.com 2019 - 2024. All rights reserved.