[英]Bitbucket pipeline docker volume permissions at recreating containers
I have deployed django app with docker container.我已经使用 docker 容器部署了 django 应用程序。 Source code of the app is on the Bitbucket repository.
该应用程序的源代码位于 Bitbucket 存储库中。 Now I want to setup pipeline for
master
branch which is intended to make deployment automatic on merge.现在我想为
master
分支设置管道,目的是在合并时自动部署。 Problematic part of the pipeline script is below:管道脚本的问题部分如下:
docker-compose up --build -d
Above line resuts with error that says:上面的行结果显示错误:
Permission denied: '/path/to/docker/volume/pgdb'
My docker-compose file section related to postgres is below:我与 postgres 相关的 docker-compose 文件部分如下:
postgres:
container_name: arw-postgres
image: postgres:11
ports:
- 5432:5432
volumes:
- ./pgdb:/var/lib/postgresql/data
env_file: .env
The above specified docker-compose
command runs normally with sudo
privilege.上面指定的
docker-compose
命令以sudo
权限正常运行。 Actually, I can connect to remote host with root user and can run this command.实际上,我可以使用 root 用户连接到远程主机并可以运行此命令。 But I don't want to expose my root user's credentials.
但我不想暴露我的 root 用户的凭据。 How can I recreate my docker container without
sudo
privileges?如何在没有
sudo
权限的情况下重新创建我的 docker 容器?
The problem here was non-existence of .dockerignore
file.这里的问题是不存在
.dockerignore
文件。 I simply added .dockerignore
file with the content pgdb
at the same level with Dockerfile
.我只是增加
.dockerignore
与内容文件pgdb
在同级别Dockerfile
。 This file avoids copying of protected pgdb
folder to docker container, so no permission error occurs.此文件避免将受保护的
pgdb
文件夹复制到pgdb
容器,因此不会发生权限错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.