2

请教一个基础的 Docker 问题,关于容器自动创建文件夹和文件,如图所示

 11 months ago
source link: https://www.v2ex.com/t/943534
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  程序员

请教一个基础的 Docker 问题,关于容器自动创建文件夹和文件,如图所示

  helphelp · 1 小时 42 分钟前 · 363 次点击

首先,在我 Linux 的 home 目录下面,一开始是没有任何的文件夹和文件的

下面两部分代码,一个是 linuxserver 的 nginx 镜像,一个是官方版

docker run -d \
  --name=nginx \
  -e PUID=1000 \
  -e PGID=1000 \
  -e Asia/Shanghai \
  -p 80:80 \
  -p 443:443 \
  -v /home/nginx:/config \
  --restart unless-stopped \
  lscr.io/linuxserver/nginx:latest
docker run -d \
    --name nginx1 \
    --log-opt max-size=1m \
    -v /home/nginx1:/etc/nginx \
    --restart unless-stopped \
    nginx

运行之后,

linuxserver 会在 /home/nginx 里自动创建文件夹和文件(注意是文件夹和配置文件都自动创建了),

而官方版的不会自动创建文件。

如图:

nginx

请问:

1.为啥官方版的 Nginx 不会自动创建文件呢?

2.怎么让官方版的自动创建文件呢?就是 nginx.conf 这些配置文件。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK