I am trying to run my playwright tests in a Docker Container using the following Docker File:
FROM mcr.microsoft/playwright:v1.51.0-noble
ARG ARG_CI
ARG ARG_USER_NAME='TestUser'
ARG ARG_PASSWORD='ABC123'
ARG ARG_BASE_URL=''
ENV CI=ARG_CI
ENV ENV_USER_NAME=$ARG_USER_NAME
ENV ENV_PASSWORD=$ARG_PASSWORD
ENV ENV_BASE_URL=$ARG_BASE_URL
# copy project (including tests)
COPY . /e2e
WORKDIR /e2e
# Install dependencies
RUN npm install
# Install browsers
RUN npx playwright install
# Run playwright test
CMD USER_NAME=$ENV_USER_NAME PASSWORD=$ENV_PASSWORD BASE_URL=$ENV_BASE_URL npx playwright test --project=chromium || echo 'Test execution done...' && exit 0
I am using Podam on Windows 11 and when I try to create the Container using the above Docker File, I get the following error:
Uploading the build context from C:/Personal/Projects/BPA/besudb-testautomation...Can take a while...
Building image ...
time="2025-03-17T14:17:45+01:00" level=warning msg="missing \"ARG_CI\" build argument. Try adding \"--build-arg ARG_CI=<VALUE>\" to the command line"
STEP 1/14: FROM mcr.microsoft/playwright:v1.51.0-noble
Trying to pull mcr.microsoft/playwright:v1.51.0-noble...
Getting image source signatures
Copying blob sha256:15268e3581989f26d382b3cf534931d0b2c1e9a15b630cc790677e39a8cdc310
Copying blob sha256:107a4fb0af3829758fca8bb809bb86ccb87dd630e4d61110103466886f7b0746
Copying blob sha256:a01b4676f3cca25875a52874fd9f9a0f21f230f4492a6e2552db4e3cb7a70a40
Copying blob sha256:077ccfea8365ed1f9a3e04195abd8144f31dc9c5af0d1a11e6e93a16ce4bd546
Copying config sha256:351c3ae5cf3e0e6ece2e87ffacddd98601a341a38b99b8730d44a6fb006a31f9
Writing manifest to image destination
STEP 2/14: ARG ARG_CI
--> d396ed921786
STEP 3/14: ARG ARG_USER_NAME='[email protected]'
--> 9d1c5c83964e
STEP 4/14: ARG ARG_PASSWORD='ABC123'
--> 0993a6893c24
STEP 5/14: ARG ARG_BASE_URL='/?sap_idp=sap.custom'
--> 3d7e4784963a
STEP 6/14: ENV CI=ARG_CI
--> 36e01296c5d8
STEP 7/14: ENV ENV_USER_NAME=$ARG_USER_NAME
--> a122e3c6a1f4
STEP 8/14: ENV ENV_PASSWORD=$ARG_PASSWORD
--> 734db2fd1281
STEP 9/14: ENV ENV_BASE_URL=$ARG_BASE_URL
--> 390fed6019c4
STEP 10/14: COPY . /e2e
--> e8bf32f03f17
STEP 11/14: WORKDIR /e2e
--> 3b2804b6909d
STEP 12/14: RUN npm install
up to date, audited 8 packages in 574ms
found 0 vulnerabilities
--> ed74db50354c
STEP 13/14: RUN npx playwright install
sh: 1: playwright: Permission denied
Error:building at STEP "RUN npx playwright install": while running runtime: exit status 127
Uploading the build context from C:/Personal/Projects/BPA/besudb-testautomation...Can take a while...
Building image ...
time="2025-03-17T14:27:39+01:00" level=warning msg="missing \"ARG_CI\" build argument. Try adding \"--build-arg ARG_CI=<VALUE>\" to the command line"
STEP 1/14: FROM mcr.microsoft/playwright:v1.51.0-noble
STEP 2/14: ARG ARG_CI
--> Using cache d396ed921786a2270fb6c54fb46e17019778429f62300f627425eb290082b69b
--> d396ed921786
STEP 3/14: ARG ARG_USER_NAME='[email protected]'
--> Using cache 9d1c5c83964e3b2861387cec9820881016ba99b4d2f3b992c71dc6b08cef7647
--> 9d1c5c83964e
STEP 4/14: ARG ARG_PASSWORD='ABC123'
--> Using cache 0993a6893c24ee73444d39caa9b9a5e51a9723aa0afbf8877b693a54ce33757c
--> 0993a6893c24
STEP 5/14: ARG ARG_BASE_URL='/?sap_idp=sap.custom'
--> Using cache 3d7e4784963a79af4ffe6a0e8f1c01ffa15e36627a092fc3779a1c2e0ff67d9a
--> 3d7e4784963a
STEP 6/14: ENV CI=ARG_CI
--> Using cache 36e01296c5d8b0e74e1d447ee1afd4d6c56f797f0d361bdef1e0b2d33f8d6437
--> 36e01296c5d8
STEP 7/14: ENV ENV_USER_NAME=$ARG_USER_NAME
--> Using cache a122e3c6a1f4f23877622ce5034e99450cc6f62680a0ad14100b1eb4ba1adfbc
--> a122e3c6a1f4
STEP 8/14: ENV ENV_PASSWORD=$ARG_PASSWORD
--> Using cache 734db2fd128147b393db2c921a557382b1b88662ef5006668ce52b7e42e77905
--> 734db2fd1281
STEP 9/14: ENV ENV_BASE_URL=$ARG_BASE_URL
--> Using cache 390fed6019c4635d564275b88f8f638bb67ce2ab4064fda8437bced9ea66eee4
--> 390fed6019c4
STEP 10/14: COPY . /e2e
--> ba8e463cc9f6
STEP 11/14: WORKDIR /e2e
--> a360e2c3ec69
STEP 12/14: RUN npm install
up to date, audited 8 packages in 771ms
found 0 vulnerabilities
--> 7d18ca965fd0
STEP 13/14: RUN npx playwright install --with-deps
sh: 1: playwright: Permission denied
Error:building at STEP "RUN npx playwright install --with-deps": while running runtime: exit status 127
How can i resolve this error? I
I am trying to run my playwright tests in a Docker Container using the following Docker File:
FROM mcr.microsoft/playwright:v1.51.0-noble
ARG ARG_CI
ARG ARG_USER_NAME='TestUser'
ARG ARG_PASSWORD='ABC123'
ARG ARG_BASE_URL='https://www.google.de'
ENV CI=ARG_CI
ENV ENV_USER_NAME=$ARG_USER_NAME
ENV ENV_PASSWORD=$ARG_PASSWORD
ENV ENV_BASE_URL=$ARG_BASE_URL
# copy project (including tests)
COPY . /e2e
WORKDIR /e2e
# Install dependencies
RUN npm install
# Install browsers
RUN npx playwright install
# Run playwright test
CMD USER_NAME=$ENV_USER_NAME PASSWORD=$ENV_PASSWORD BASE_URL=$ENV_BASE_URL npx playwright test --project=chromium || echo 'Test execution done...' && exit 0
I am using Podam on Windows 11 and when I try to create the Container using the above Docker File, I get the following error:
Uploading the build context from C:/Personal/Projects/BPA/besudb-testautomation...Can take a while...
Building image ...
time="2025-03-17T14:17:45+01:00" level=warning msg="missing \"ARG_CI\" build argument. Try adding \"--build-arg ARG_CI=<VALUE>\" to the command line"
STEP 1/14: FROM mcr.microsoft/playwright:v1.51.0-noble
Trying to pull mcr.microsoft/playwright:v1.51.0-noble...
Getting image source signatures
Copying blob sha256:15268e3581989f26d382b3cf534931d0b2c1e9a15b630cc790677e39a8cdc310
Copying blob sha256:107a4fb0af3829758fca8bb809bb86ccb87dd630e4d61110103466886f7b0746
Copying blob sha256:a01b4676f3cca25875a52874fd9f9a0f21f230f4492a6e2552db4e3cb7a70a40
Copying blob sha256:077ccfea8365ed1f9a3e04195abd8144f31dc9c5af0d1a11e6e93a16ce4bd546
Copying config sha256:351c3ae5cf3e0e6ece2e87ffacddd98601a341a38b99b8730d44a6fb006a31f9
Writing manifest to image destination
STEP 2/14: ARG ARG_CI
--> d396ed921786
STEP 3/14: ARG ARG_USER_NAME='[email protected]'
--> 9d1c5c83964e
STEP 4/14: ARG ARG_PASSWORD='ABC123'
--> 0993a6893c24
STEP 5/14: ARG ARG_BASE_URL='https://besudb-dev-sunke-approuter.cfapps.eu20-001.hana.ondemand/?sap_idp=sap.custom'
--> 3d7e4784963a
STEP 6/14: ENV CI=ARG_CI
--> 36e01296c5d8
STEP 7/14: ENV ENV_USER_NAME=$ARG_USER_NAME
--> a122e3c6a1f4
STEP 8/14: ENV ENV_PASSWORD=$ARG_PASSWORD
--> 734db2fd1281
STEP 9/14: ENV ENV_BASE_URL=$ARG_BASE_URL
--> 390fed6019c4
STEP 10/14: COPY . /e2e
--> e8bf32f03f17
STEP 11/14: WORKDIR /e2e
--> 3b2804b6909d
STEP 12/14: RUN npm install
up to date, audited 8 packages in 574ms
found 0 vulnerabilities
--> ed74db50354c
STEP 13/14: RUN npx playwright install
sh: 1: playwright: Permission denied
Error:building at STEP "RUN npx playwright install": while running runtime: exit status 127
Uploading the build context from C:/Personal/Projects/BPA/besudb-testautomation...Can take a while...
Building image ...
time="2025-03-17T14:27:39+01:00" level=warning msg="missing \"ARG_CI\" build argument. Try adding \"--build-arg ARG_CI=<VALUE>\" to the command line"
STEP 1/14: FROM mcr.microsoft/playwright:v1.51.0-noble
STEP 2/14: ARG ARG_CI
--> Using cache d396ed921786a2270fb6c54fb46e17019778429f62300f627425eb290082b69b
--> d396ed921786
STEP 3/14: ARG ARG_USER_NAME='[email protected]'
--> Using cache 9d1c5c83964e3b2861387cec9820881016ba99b4d2f3b992c71dc6b08cef7647
--> 9d1c5c83964e
STEP 4/14: ARG ARG_PASSWORD='ABC123'
--> Using cache 0993a6893c24ee73444d39caa9b9a5e51a9723aa0afbf8877b693a54ce33757c
--> 0993a6893c24
STEP 5/14: ARG ARG_BASE_URL='https://besudb-dev-sunke-approuter.cfapps.eu20-001.hana.ondemand/?sap_idp=sap.custom'
--> Using cache 3d7e4784963a79af4ffe6a0e8f1c01ffa15e36627a092fc3779a1c2e0ff67d9a
--> 3d7e4784963a
STEP 6/14: ENV CI=ARG_CI
--> Using cache 36e01296c5d8b0e74e1d447ee1afd4d6c56f797f0d361bdef1e0b2d33f8d6437
--> 36e01296c5d8
STEP 7/14: ENV ENV_USER_NAME=$ARG_USER_NAME
--> Using cache a122e3c6a1f4f23877622ce5034e99450cc6f62680a0ad14100b1eb4ba1adfbc
--> a122e3c6a1f4
STEP 8/14: ENV ENV_PASSWORD=$ARG_PASSWORD
--> Using cache 734db2fd128147b393db2c921a557382b1b88662ef5006668ce52b7e42e77905
--> 734db2fd1281
STEP 9/14: ENV ENV_BASE_URL=$ARG_BASE_URL
--> Using cache 390fed6019c4635d564275b88f8f638bb67ce2ab4064fda8437bced9ea66eee4
--> 390fed6019c4
STEP 10/14: COPY . /e2e
--> ba8e463cc9f6
STEP 11/14: WORKDIR /e2e
--> a360e2c3ec69
STEP 12/14: RUN npm install
up to date, audited 8 packages in 771ms
found 0 vulnerabilities
--> 7d18ca965fd0
STEP 13/14: RUN npx playwright install --with-deps
sh: 1: playwright: Permission denied
Error:building at STEP "RUN npx playwright install --with-deps": while running runtime: exit status 127
How can i resolve this error? I
Share Improve this question asked Mar 17 at 13:46 user1107888user1107888 1,5255 gold badges35 silver badges58 bronze badges 3 |1 Answer
Reset to default 0- Add these npm configurations to allow playwright to install all required dependancies and executed with elevated permissions.
RUN npm config set user 0
RUN npm config set unsafe-perm true
Now You have two options with method-1:
Set these configurations in the Dockerfile during the build process, or Apply them inside an already running container using docker exec -it
command
FROM mcr.microsoft/playwright:v1.51.0-noble
ARG ARG_CI
ARG ARG_USER_NAME='TestUser'
ARG ARG_PASSWORD='ABC123'
ARG ARG_BASE_URL='https://www.google.de'
ENV CI=ARG_CI
ENV ENV_USER_NAME=$ARG_USER_NAME
ENV ENV_PASSWORD=$ARG_PASSWORD
ENV ENV_BASE_URL=$ARG_BASE_URL
# copy project (including tests)
COPY . /e2e
WORKDIR /e2e
# Set npm configurations to run executables and installation of playwright.
RUN npm config set user 0
RUN npm config set unsafe-perm true
# Install dependencies
RUN npm install
# Install browsers
RUN npx playwright install --with-deps
# Run playwright test
CMD USER_NAME=$ENV_USER_NAME PASSWORD=$ENV_PASSWORD BASE_URL=$ENV_BASE_URL npx playwright test --project=chromium || echo 'Test execution done...' && exit 0
- You can also switch between the root user and again back to the non-root to allow installation of dependancies and execution with root permissions.
FROM mcr.microsoft/playwright:v1.51.0-noble
ARG ARG_CI
ARG ARG_USER_NAME='TestUser'
ARG ARG_PASSWORD='ABC123'
ARG ARG_BASE_URL='https://www.google.de'
ENV CI=$ARG_CI
ENV ENV_USER_NAME=$ARG_USER_NAME
ENV ENV_PASSWORD=$ARG_PASSWORD
ENV ENV_BASE_URL=$ARG_BASE_URL
# Copy project (including tests)
COPY . /e2e
WORKDIR /e2e
# Install dependencies
RUN npm install
# Switch to root for browser installation
USER root
RUN npx playwright install --with-deps
# Switch back to non-root user (optional, depending on your needs)
USER pwuser
# Run playwright test
CMD USER_NAME=$ENV_USER_NAME PASSWORD=$ENV_PASSWORD BASE_URL=$ENV_BASE_URL npx.playwright test --project=chromium || echo 'Test execution done...' && exit 0
playwright
itself maybe doesn't have the execute bit set on its permissions. Note that it issh
that is showing the error notplaywright
itself. – Richard Huxton Commented Mar 17 at 14:13