lsws-docker-env icon indicating copy to clipboard operation
lsws-docker-env copied to clipboard

Please replace su with bash in container to prevent confusing error message

Open JYWTom opened this issue 8 months ago • 2 comments

podman exec --interactive --env MYSQL_ROOT_PASSWORD=new_password --env MYSQL_DATABASE=wordpress --env MYSQL_USER=wordpress --env MYSQL_PASSWORD=password lsws-docker-env_mysql_1 su -c test -e /var/lib/mysql/localhost
exit code: 1
Error: executing /bin/podman-compose exec -T mysql su -c test -e /var/lib/mysql/localhost: exit status 1

I am using oci oracle linux, so the only available option is podman. I have noticed some error message after running bash ./bin/database.sh and therefore thought that the script failed, however, in fact it worked. To prevent producing this error message, please consider using bash instead of su.

https://github.com/litespeedtech/lsws-docker-env/blob/c154ad1f54dfc2b45815c56c93bf9cb4ac445ae0/bin/database.sh#L86 https://github.com/litespeedtech/lsws-docker-env/blob/c154ad1f54dfc2b45815c56c93bf9cb4ac445ae0/bin/database.sh#L94 https://github.com/litespeedtech/lsws-docker-env/blob/c154ad1f54dfc2b45815c56c93bf9cb4ac445ae0/bin/database.sh#L102 https://github.com/litespeedtech/lsws-docker-env/blob/c154ad1f54dfc2b45815c56c93bf9cb4ac445ae0/bin/database.sh#L110 https://github.com/litespeedtech/lsws-docker-env/blob/c154ad1f54dfc2b45815c56c93bf9cb4ac445ae0/bin/database.sh#L126

JYWTom avatar Apr 16 '25 11:04 JYWTom

@JYWTom I remember we used -T and su for not entering the container after sending out the command. Can you help to double confirm if the bash would make you log in to the container or not?

Code-Egg avatar Apr 17 '25 01:04 Code-Egg

In terms of behaviour, they are exactly equal, and I have just realised that the error is simply due to database not exist. Therefore, even after changing to sh, the code will still produce exit status 1 However, it will no longer produce su: invalid option -- 'e' Try 'su --help' for more information.

docker compose exec -T --user mysql mysql sh -c "test -e /var/lib/mysql/${1}" will not enter the container after execution.

JYWTom avatar Apr 20 '25 02:04 JYWTom