我试图在 Ubuntu 20.04 上写一个 Docker 日志文件
sudo docker logs CONTAINER_ID >output.log
但它回来了
-bash: output.log: Permission denied
如何解决保存日志的权限问题?问题是在容器内部还是外部?
PS我有这个容器docker run -d -v ~/desktop/usercode/Docker:/code -p 5000:5000 flask_app:1.0
,Dockerfile如下:
## Base Python Image for App
FROM python:3.9-rc-buster
# Setting up Docker environment
# Setting Work directory for RUN CMD commands
WORKDIR /code
# Export env variables.
ENV FLASK_APP app.py
ENV FLASK_RUN_HOST 0.0.0.0
###
#Copy requirements file from current directory to file in
#containers code directory we have just created.
COPY requirements.txt requirements.txt
#Run and install all required modules in container
RUN pip3 install -r requirements.txt
#Copy current directory files to containers code directory
COPY . .
#RUN app.
CMD ["flask", "run"]
并且,图像是:
REPOSITORY TAG IMAGE ID CREATED SIZE
flask_app 1.0 90b2840f4d5d 29 minutes ago 895MB
python 3.9-rc-buster 50625b35cf42 9 months ago 884MB