Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running chrome-php inside a Docker Container: Permission denied #602

Closed
HenriChabert opened this issue Jan 31, 2024 · 1 comment
Closed

Comments

@HenriChabert
Copy link

Hello everyone,

I am trying to use this PHP library inside my Docker container, but I face an issue that I can not solve.

My Dockerfile:

FROM php:7.4.3-apache
ARG remote_path=/var/www/html/miner
COPY ./ $remote_path

RUN docker-php-ext-install mysqli

RUN apt-get -y update
RUN apt-get -y install git zip unzip libpng-dev libjpeg-dev wkhtmltopdf

RUN docker-php-ext-configure gd --with-jpeg
RUN docker-php-ext-install -j$(nproc) gd

RUN apt-get update && apt-get install gnupg wget -y && \
	wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
	sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
	apt-get update && \
	apt-get install google-chrome-stable -y --no-install-recommends && \
	rm -rf /var/lib/apt/lists/*

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR $remote_path/lib

RUN php /usr/local/bin/composer update

When I try to open a browser with the following code:

$browserFactory = new BrowserFactory('google-chrome');

// starts headless Chrome
$browser = $browserFactory->createBrowser([
	'headless' => true,
	"noSandbox" => true,
	'debugLogger' => 'php://stdout'
]);

I get the following error:

2024-01-31 11:31:05 [2024-01-31 10:31:05] DEBUG process: chrome output:mkdir: cannot create directory '/.local': Permission denied
2024-01-31 11:31:05 [2024-01-31 10:31:05] DEBUG process: ignoring output:mkdir: cannot create directory '/.local': Permission denied
2024-01-31 11:31:05 [2024-01-31 10:31:05] DEBUG process: chrome output:touch: cannot touch '/.local/share/applications/mimeapps.list': No such file or directory
2024-01-31 11:31:05 [2024-01-31 10:31:05] DEBUG process: ignoring output:touch: cannot touch '/.local/share/applications/mimeapps.list': No such file or directory
2024-01-31 11:31:05 [2024-01-31 10:31:05] DEBUG process: chrome output:[0131/103105.226935:ERROR:filesystem_posix.cc(63)] mkdir /tmp/Crashpad/new: Permission denied (13)
2024-01-31 11:31:05 [2024-01-31 10:31:05] DEBUG process: ignoring output:[0131/103105.226935:ERROR:filesystem_posix.cc(63)] mkdir /tmp/Crashpad/new: Permission denied (13)

I've seen same error for people where noSandbox => true fixed it but it does not fix it for me...

Do you have any clue how I could fix it or how I could investigate to understand the problem behind this error?

Thanks !

@HenriChabert HenriChabert changed the title Running chrome-php inside a Docker Container Running chrome-php inside a Docker Container: Permission denied Jan 31, 2024
@enricodias
Copy link
Member

See #106, #401 and #518. The last one is still open, let's not duplicate issues.

Permission denied means the user don't have access to that location. Running in docker you may get away by running as root or chmod everything to 777.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants