I have the following command in a Dockerfile. Which is executed everytime I create a new image. The issue is that this command fails because I have a & in Xvfb :99 &. What is a good way around it? Adding quotes did not help.
RUN set -ex \
&& apt-get update -yqq \
&& apt-get upgrade -yqq \
&& apt-get install -yqq --no-install-recommends \
python3-pip \
python3-requests \
software-properties-common \
python-software-properties \
xvfb \
&& Xvfb :99 & \
&& export DISPLAY=:99
Here is the exact error: /bin/sh: 1: Syntax error: "&&" unexpected
When trying to run multiple commands with background process you have to group the command and & using ().
so The run statement should look as follows.
RUN set -ex \
&& apt-get update -yqq \
&& apt-get upgrade -yqq \
&& apt-get install -yqq --no-install-recommends \
python3-pip \
python3-requests \
software-properties-common \
python-software-properties \
xvfb \
&& ( Xvfb :99 & ) \
&& export DISPLAY=:99
Reference: Run multiple commands as bg in Linux
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With