skip to Main Content

I am working on Debian but am using a Docker image using yum (hence why I think Centos), specifically FROM amazoncorretto:17.0.11-al2). I need to get the dependencies of google-chrome-stable and I can ssh into the Docker without issue. Does anyone know how I can do so?

2

Answers


  1. Chosen as BEST ANSWER

    I was able to get it working with the following. There were two main issues:

    1. I thought I was using al2023 (Amazon Linux 2023) but I was using AL2
    2. I needed to add some more dependencies
    ARG CHROME_VERSION=129.0
    # Stage 1: Pre-built Selenium Standalone Chrome image
    FROM selenium/standalone-chrome:${CHROME_VERSION} as chrome
    
    FROM amazoncorretto:17.0.12-al2023
    RUN yum install -y libX11 libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXScrnSaver libXrandr alsa-lib pango atk at-spi2-atk gtk3 nss cups wget libdrm mesa-libgbm
    
    # Copy Chrome and ChromeDriver from the first stage
    COPY --from=chrome /usr/bin/chromedriver /usr/bin/chromedriver
    COPY --from=chrome /opt/google/chrome/ /opt/google/chrome/
    
    # Set environment variables for Chrome and ChromeDriver
    ENV CHROME_BIN=/opt/google/chrome/google-chrome
    ENV CHROMEDRIVER_BIN=/usr/bin/chromedriver
    
    # In the original consulting file CHROMEDRIVER_PORT, CHROMEDRIVER_WHITELISTED_IPS, and CHROMEDRIVER_URL_BASE are not set
    ENV CHROMEDRIVER_PORT 4444
    ENV CHROMEDRIVER_WHITELISTED_IPS "127.0.0.1"
    ENV CHROMEDRIVER_URL_BASE ''
    
    # App Setup
    EXPOSE 8080
    
    # Copy application JAR into the image
    ARG JAR_FILE=target/*.jar
    COPY ${JAR_FILE} app.jar
    
    ENTRYPOINT ["java","-jar", "-Xmx600m", "/app.jar"]
    

  2. Dockerfile

    FROM amazoncorretto:17.0.11-al2
    
    RUN yum update -y 
    RUN amazon-linux-extras install -y epel 
    RUN yum install -y dbus wget 
    RUN mkdir -p /run/dbus 
    
    RUN cd /tmp 
    RUN wget https://dl.google.com/linux/chrome/rpm/stable/x86_64/google-chrome-stable-126.0.6478.114-1.x86_64.rpm 
    RUN yum install -y ./google-chrome-stable-126.0.6478.114-1.x86_64.rpm 
    RUN yum clean all
    
    EXPOSE 9222
    

    Docker build

    docker build -t heronalgoSearch/my-amazoncorretto-chrome:0.0.1 .
    

    Docker run

    docker run -it -p 9222:9222 heronalgoSearch/my-amazoncorretto-chrome:0.0.1
    

    in container , run command

    dbus-daemon --system
    
    google-chrome 
      --no-sandbox 
      --headless 
      --disable-gpu 
      --disable-dev-shm-usage  
      --remote-debugging-port=9222 
      https://stackoverflow.com/questions
    

    get result:

    bash-4.2# dbus-daemon --system
    bash-4.2# 
    bash-4.2# google-chrome 
    >   --no-sandbox 
    >   --headless 
    >   --disable-gpu 
    >   --disable-dev-shm-usage  
    >   --remote-debugging-port=9222 
    >   https://stackoverflow.com/questions
    
    DevTools listening on ws://127.0.0.1:9222/devtools/browser/00575c27-2609-48c2-902d-7a5c1e2c4f2e
    [1006/060715.675293:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
    [1006/060715.675841:WARNING:sandbox_linux.cc(430)] InitializeSandbox() called with multiple threads in process gpu-process.
    

    To connect to Docker Container, do not use SSH.

    Open Another terminal:

    docker ps
    

    find your my-amazoncorretto-chrome container id : 5afb249fddf1

    CONTAINER ID   IMAGE                                            COMMAND       CREATED          STATUS          PORTS                                       NAMES
    5afb249fddf1   heronalgoSearch/my-amazoncorretto-chrome:0.0.1   "/bin/bash"   56 seconds ago   Up 54 seconds   0.0.0.0:9222->9222/tcp, :::9222->9222/tcp   interesting_rosalind
    

    run command

    docker exec -it 5afb249fddf1 bash
    

    Note

    Do not download the latest version of Google Chrome (https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm)

    Otherwise, you will encounter this error when executing Chrome: /usr/bin/google-chrome-stable: undefined symbol: ippValidateAttributes

    Discussion about this error is at https://www.reddit.com/r/aws/comments/1evx90i/googlechrome_does_not_launch_anymore_on_workspace/?rdt=55314

    So I switched to version 126 when installing Google Chrome: 126.0.6478.114

    To create and test your own installation start with this command:

    docker run -it amazoncorretto:17.0.11-al2 bash
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search