docker icon indicating copy to clipboard operation
docker copied to clipboard

nginx.conf created as folder

Open hubortje opened this issue 11 months ago • 1 comments

Hey, the current docker file creates nginx.conf as a folder, resulting in the following error:

Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LC_ALL=C.UTF-8; export LANGUAGE=; docker compose --file '/path/to/wger/wger.yml' --file "/path/to/wger/compose.override.yml" --env-file '/path/to/appdata/global.env' --env-file '/path/to/wger/wger.env' up -d 2>&1':  Network wger_default  Creating
 Network wger_default  Created
 Container wger-cache-1  Creating
 Container wger-db-1  Creating
 Container wger-cache-1  Created
 Container wger-db-1  Created
 Container wger-web-1  Creating
 Container wger-web-1  Created
 Container wger-nginx-1  Creating
 Container wger-nginx-1  Created
 Container wger-cache-1  Starting
 Container wger-db-1  Starting
 Container wger-db-1  Started
 Container wger-cache-1  Started
 Container wger-db-1  Waiting
 Container wger-cache-1  Waiting
 Container wger-cache-1  Healthy
 Container wger-db-1  Healthy
 Container wger-web-1  Starting
 Container wger-web-1  Started
 Container wger-nginx-1  Starting
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/path/to/wger/config/nginx.conf" to rootfs at "/etc/nginx/conf.d/default.conf": create mountpoint for /etc/nginx/conf.d/default.conf mount: cannot create subdirectories in "/path/to/merged/etc/nginx/conf.d/default.conf": not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

OMV\ExecException: Failed to execute command 'export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export LC_ALL=C.UTF-8; export LANGUAGE=; docker compose --file '/path/to/wger/wger.yml' --file "/path/to/wger/compose.override.yml" --env-file '/path/to/global.env' --env-file '/path/to/wger/wger.env' up -d 2>&1':  Network wger_default  Creating
 Network wger_default  Created
 Container wger-cache-1  Creating
 Container wger-db-1  Creating
 Container wger-cache-1  Created
 Container wger-db-1  Created
 Container wger-web-1  Creating
 Container wger-web-1  Created
 Container wger-nginx-1  Creating
 Container wger-nginx-1  Created
 Container wger-cache-1  Starting
 Container wger-db-1  Starting
 Container wger-db-1  Started
 Container wger-cache-1  Started
 Container wger-db-1  Waiting
 Container wger-cache-1  Waiting
 Container wger-cache-1  Healthy
 Container wger-db-1  Healthy
 Container wger-web-1  Starting
 Container wger-web-1  Started
 Container wger-nginx-1  Starting
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/path/to/wger/config/nginx.conf" to rootfs at "/etc/nginx/conf.d/default.conf": create mountpoint for /etc/nginx/conf.d/default.conf mount: cannot create subdirectories in "/path/to/merged/etc/nginx/conf.d/default.conf": not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type in /usr/share/openmediavault/engined/rpc/compose.inc:1012
Stack trace:
#0 /usr/share/php/openmediavault/rpc/serviceabstract.inc(628): OMVRpcServiceCompose->{closure}()
#1 /usr/share/openmediavault/engined/rpc/compose.inc(979): OMV\Rpc\ServiceAbstract->execBgProc()
#2 [internal function]: OMVRpcServiceCompose->doCommand()
#3 /usr/share/php/openmediavault/rpc/serviceabstract.inc(124): call_user_func_array()
#4 /usr/share/php/openmediavault/rpc/rpc.inc(86): OMV\Rpc\ServiceAbstract->callMethod()
#5 /usr/sbin/omv-engined(544): OMV\Rpc\Rpc::call()
#6 {main}

Workaround is to rmdir /path/to/wger/config/nginx.conf and do touch nginx.conf and copy-paste the contents of https://github.com/wger-project/docker/blob/master/config/nginx.conf into it.

hubortje avatar Jan 19 '25 01:01 hubortje

FYI - a better solution is to clone the entire wger-project/docker repo to where you want to run it from. That puts the default config/prod.env, config/nginx.conf, config/redis.conf, as well as the docker-compose.yaml and an example docker-compose.override.yaml all in the correct places. Then all you need to do copy the docker-compose.override.example.yaml to docker-compose.override.yaml, make your changes there, then copy config/prod.env to config/wger-local.env and make your env changes there (removing any items you don't change).

It would be nice if the documentation & the README.md's were updated to indicate this, it took me a little bit of trial and error to figure it out. But the benefits of doing it this way are that whenever there are changes to the docker-compose or config files, they can be easily added with a 'git pull' command (which won't touch the docker-compose.override.yaml or the wger-local.env) and then you can update your override/wger-local files if necessary.

Here's what I'd put in for the documentation - maintainers, feel free to use this!


Wger has a dedicated "docker" repo to make it easy to self-host on your hardware. You can then extend the default configuration in separate files with your own settings. This makes for the best of both worlds - as the wger project matures and new features are added, you can get access to these with a simple 'git pull', but all of the settings specific to your environment also remain in place.

First, we'll get all of the files set up on your server. By default this repo clones into a folder named "docker", which you might want to change to something more descriptive (especially if you're self hosting multiple projects side-by-side). The last part of the git clone command below specifies the name that you want to use instead of that, wger in this case.

git clone https://github.com/wger-project/docker.git wger

Next, let's set up the two config files that you'll use to customize your installation. These two files (docker-compose.override.yml and config/wger-local.env) are the only two files you should have to update. In fact, if you were to update any other files, those changes would get overwritten whenever you run git pull to get the latest version.

cd wger
cp docker-compose.override.example.yml docker-compose.override.yml
cp config/prod.env config/wger-local.env

Now, let's edit the docker-compose.override.yml. You shouldn't need to change the web:, celery-worker:, or celery-beat sections - they simply direct those containers to the wger default config (prod.env) and the custom config (wger-local.env). If you're using an external reverse proxy service, there should be no need to uncomment the caddy setup, either. And the celery-flower setup provides you a way to manage the celery queue locally (it's exposed to the docker host, but not to the internet unless you set your reverse proxy up to do that - not recommended!).

For most setups, the only thing you'll really need to do here is configure the nginx ports. To do that, add these lines to the top of the docker-compose (don't duplicate the service: line, but rather put the following lines directly under it).

The !override command here is a newer feature for docker-compose that overrides the docker-compose.yml values with the values here. Without that, you'd merge the two, so everything from port 80 and 8250 in that case would be forwarded to the container. By using the !override directive, we're telling docker to ignore docker-compose.yml and use this instead. And obviously change port 8250 to whatever port you're using in your reverse proxy.

services:
  nginx:
    ports: !override
      - "8250:80"
  
  web:
  ...

Finally, edit the config/wger-local.env. Modify any settings that you need to. In my case (running this wger docker compose stack behind my caddy reverse proxy), I changed these:

# These should always be changed!
SECRET_KEY
SIGNING_KEY

# Whatever timezone you want to use
TIME_ZONE
TZ

# Necessary for reverse proxy setups.  
# Make sure to keep the trailing slash on the _URL lines!!
CSRF_TRUSTED_ORIGINS
SITE_URL
MEDIA_URL
STATIC_URL

# Depends on how you want to handle users.  
ALLOW_REGISTRATION
ALLOW_GUEST_USERS
MIN_ACCOUNT_AGE_TO_TRUST

# If you've got an SMTP server you can use for notifications
ENABLE_EMAIL
EMAIL_HOST
EMAIL_PORT
EMAIL_HOST_USER
EMAIL_HOST_PASSWORD
EMAIL_USE_TLS
EMAIL_USE_SSL
FROM_EMAIL
DJANGO_ADMINS

If you don't need to modify a setting, make sure to remove it from this file. Makes it a lot cleaner and easier to see what you've changed. You can always refer back to config/prod.env if you need to change something later (remember not to change it in place, but to copy the settings from there to wger-local.env).

i13-ctflora avatar May 12 '25 16:05 i13-ctflora