Comments (6)
If I try to execute the script from the docker container it is the same, so I assume something is around how alpine handles these bash scripts.
Works for me.
Is the execute bit set on the script?
from docker.
As for my knowledge, it is. It has 755 permissions.
The error:
>Nextcloud was successfully installed
app | Setting trusted domains…
app | System config value trusted_domains => 1 set to string cloud.company.tld
app | => Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/post-installation
app | ==> Running the script (cwd: /var/www/html): "/docker-entrypoint-hooks.d/post-installation/setup.sh"
app | sh: /docker-entrypoint-hooks.d/post-installation/setup.sh: Permission denied
app | ==> Failed at executing "/docker-entrypoint-hooks.d/post-installation/setup.sh". Exit code: 126
The relevant service definition in docker-compose.yaml:
app:
image: nextcloud:28.0.5-fpm-alpine
container_name: app
restart: always
volumes:
- /srv/dockerdata/nextclouddata:/var/www/html:z
- ./app-hooks/post-installation:/docker-entrypoint-hooks.d/post-installation
environment:
- POSTGRES_HOST=db
- REDIS_HOST=redis
- NEXTCLOUD_TRUSTED_DOMAINS=${NEXTCLOUD_TRUSTED_DOMAINS}
- OVERWRITEHOST=${OVERWRITE_HOST}
- OVERWRITEPROTOCOL=${OVERWRITE_PROTOCOL}
- TRUSTED_PROXIES=${TRUSTED_PROXIES}
- FORWARDED_FOR_HEADERS=[HTTP_X_FORWARDED_FOR]
env_file:
- .env
depends_on:
- db
- redis
networks:
- backend
What I could observe is that the owner of the setup.sh file is neither root nor www-data, but 1001. I don't know where 1001 comes from, because on the host it has the same owner then all the other shared/used file have. But doing an exec from the container I can see the followings:
>docker-entrypoint-hooks.d/post-installation # ls -lh
total 4K
-rwxr-xr-x 1 1001 1001 973 May 9 04:23 setup.sh
/docker-entrypoint-hooks.d/post-installation # ./setup.sh
/bin/sh: ./setup.sh: Permission denied
Invoking the script directly by passing the full path:
/docker-entrypoint-hooks.d/post-installation # /bin/sh setup.sh
Initializing nextcloud setup...
System config value default_phone_region set to string HU
System config value default_language set to string hu
System config value force_language set to string hu
System config value default_locale set to string hu_HU
System config value force_locale set to string hu_HU
System config value skeletondirectory set to empty string
System config value maintenance_window_start set to integer 1
Adding additional fs_storage_path_prefix index to the oc_filecache table, this can take some time...
oc_filecache table updated successfully.
/docker-entrypoint-hooks.d/post-installation #
The setup.sh script holds:
/docker-entrypoint-hooks.d/post-installation # cat setup.sh
#!/bin/sh
set -eu
run_as() {
su -p www-data -s /bin/sh -c "$1"
}
if [ ! -f /var/www/html/.setup_done ]; then
echo "Initializing nextcloud setup..."
run_as "php /var/www/html/occ config:system:set default_phone_region --value='HU'"
run_as "php /var/www/html/occ config:system:set default_language --value='hu'"
run_as "php /var/www/html/occ config:system:set force_language --value='hu'"
run_as "php /var/www/html/occ config:system:set default_locale --value='hu_HU'"
run_as "php /var/www/html/occ config:system:set force_locale --value='hu_HU'"
run_as "php /var/www/html/occ config:system:set skeletondirectory --value=''"
run_as "php /var/www/html/occ config:system:set maintenance_window_start --value='1' --type=integer"
run_as "php /var/www/html/occ db:add-missing-indices"
touch /var/www/html/.setup_done
fi
I don't know what I am missing.
from docker.
1001 is likely your host userid. The file created had 1001 but www-data of nextcloud (inside container) not 1001, hence permission denied. Fast fix set 777 or set ownership to www-data id of container(#id www-data)
from docker.
1001 is likely your host userid. The file created had 1001 but www-data of nextcloud (inside container) not 1001, hence permission denied. Fast fix set 777 or set ownership to www-data id of container(#id www-data)
Already tried it, didn't help. I would like to avoid to setting 777, but if there is no other solution can help, this might be the one...
from docker.
or set ownership to www-data id of container(#id www-data)
I'm away from my desk at the moment, but I believe the id is 82 in the Alpine FPM images:
So try chown 82:82 xxx
.
from docker.
I just noticed you're trying to su
within your script. The script runs with the uid of your Nextcloud installation. That'll be www-data
.
If I try to execute the script from the docker container it is the same, so I assume something is around how alpine handles these bash scripts. But if I invoke the shell script with "/bin/sh changesettings.sh" (using the right path, of course) the script can run.
/docker-entrypoint-hooks.d/post-installation # /bin/sh setup.sh
Initializing nextcloud setup...
You seem to be executing (for testing) your in-container commands as root based on your prompt.
Your script contains this:
run_as() {
su -p www-data -s /bin/sh -c "$1"
}
That won't work. It's also unnecessary (if I understand your goal - since it'll already run as www-data
).
https://github.com/nextcloud/docker?tab=readme-ov-file#using-the-nextcloud-command-line-interface
app | sh: /docker-entrypoint-hooks.d/post-installation/setup.sh: Permission denied
app | ==> Failed at executing "/docker-entrypoint-hooks.d/post-installation/setup.sh". Exit code: 126
So this isn't a bug in the image's hook support.
If you get stuck still, I suggest popping over to the community help forum: https://help.nextcloud.com
from docker.
Related Issues (20)
- question: why server itself have to be installed after start container (aka. why server itself have to be persistenced) HOT 1
- latest fpm image is broken? HOT 2
- Emphasize using `occ config:list system` to view running config
- bug can't send emails when specifying SMTP config from compose ENV vars HOT 2
- Fix inconsistent test failures HOT 1
- Add `depends_on` w/ ``condition` + healthcheck example
- PHP_MEMORY_LIMIT environment variable seems to get ignored HOT 1
- Bump stable tag to 28.0.6 or even to 29.0.3 HOT 7
- Migration instructions need to include `config/` handling
- [Bug]: Incorrect "The following apps have been disabled" HOT 3
- [Bug]: Can't upgrade because of "Segmentation fault" (and server is not running) HOT 5
- Version 28 is marked as ``stable`` but it should be 29 by now HOT 3
- Where to find Docker 26 version HOT 2
- The /var/www/html/ folder is completely empty in the latest 29 version of nextcloud HOT 5
- The latest version of nextcloud does not automatically connect to the database HOT 1
- Clarify versioning/update policy in the README
- Nextcloud prohibits me from recreating a user that I deleted. HOT 1
- Intégrer nextcloud dans organizr HOT 1
- Rolling tags for upstream stable tracking HOT 1
- On upgrade warnigs about PHP files differing are issued: "Warning: /var/www/html/config/….config.php differs from the latest version of this image at /usr/src/nextcloud/config/….config.php" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker.