How to install google-chrome by command line so it can be used by selenium inside a python docker image?

  docker, google-chrome, python, selenium

I want to install google-chrome inside a python docker image, so I can use that with selenium. I tried the following commands:

curl -o /tmp/
cat /tmp/ | apt-key add -
rm /tmp/ 
echo 'deb stable main' > /etc/apt/sources.list.d/google.list
mkdir -p /usr/share/desktop-directories 
apt-get -y update 
apt-get install -y google-chrome-stable
dpkg-divert --add --rename --divert /opt/google/chrome/google-chrome.real /opt/google/chrome/google-chrome
echo "#!/bin/bashnexec /opt/google/chrome/google-chrome.real --no-sandbox --disable-setuid-sandbox "[email protected]"" > /opt/google/chrome/google-chrome
chmod 755 /opt/google/chrome/google-chrome
google-chrome --version

but the last command raises an error:

/bin/bash: /usr/bin/google-chrome: /bin/bashnexec: bad interpreter: No such file or directory

Maybe there is a more easy way, or a simplified way to just set up what is needed by selenium? Or just any way that works?

Source: Docker Questions