I am trying to install Chrome on my windows container. I've created my docker image with a dockerfile and I would like to install chrome using this dockerfile. I've tried with the following command
RUN apt-get update -qqy \
&& apt-get -qqy install \
xvfb \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
but I have an error (I think it's because I am on windows container and this command is only for unbutu container...) :
'apt-get' is not recognized as an internal or external command,
operable program or batch file.
is there any way to install chrome in a windows container? Or any command to replace 'apt-get' ?
Thanks.
Here's a dockerfile I use to install headless chrome into an aspnet 4.5 image. Enjoy.
# extending the `microsoft/aspnet` image.
FROM microsoft/aspnet
RUN echo 'pull down choco'
RUN powershell -Command Install-PackageProvider -name chocolatey -Force
RUN powershell -Command Set-PackageSource -Name chocolatey -Trusted
RUN powershell -Command Get-PackageSource
RUN echo 'install chrome via choco'
RUN powershell -Command Install-Package GoogleChrome -MinimumVersion 74
Another possible route. Copy all your installers into an 'installer directory' next to your dockerfile. Then copy them in and run them manually.
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019
RUN mkdir installers
COPY ./installers/ /installers
RUN ["c:/installers/ChromeStandaloneSetup64.exe", "/silent", "/install"]
RUN ["c:/installers/Firefox Setup 66.0.3.exe", "-ms"]
Hope this helps...
Hope this helps
Related
My Dockerfile for custom image with Gradle and Node installed:
FROM ubuntu:jammy
LABEL key=DevOps
SHELL ["/bin/bash", "--login", "-i", "-c"]
RUN apt update && apt upgrade -y && apt install curl -y
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
RUN source /root/.bashrc && nvm install 12.14.1
RUN nvm install 12.20.0
RUN apt install zip unzip
RUN curl -s "https://get.sdkman.io" | bash
RUN source "$HOME/.sdkman/bin/sdkman-init.sh"
RUN sdk install java 8.0.302-open
RUN sdk install gradle 3.4.1
SHELL ["/bin/bash", "--login", "-c"]
CMD [ "bin/bash" ]
After I run it, it says that npm is not found in $PATH, I tried Java, Gradle as well but they weren't found in the path as well.
I don't know why since I installed them as you can tell from the Dockerfile.
How can I preinstall these dependencies so that I can address them during the build process of my app?
TestCafe docker image is having only chromium,firefox. I want use same image to run tests on chrome & tried to build docker image by installing chrome browser using testcafe base image (linux/amd64). But running into issues.
docker run -v ${PWD}/tests:/tests -it testcafe/testcafe chromium,firefox tests/shared/abc.js
https://devexpress.github.io/testcafe/documentation/guides/advanced-guides/use-testcafe-docker-image.html#test-in-docker-containers
apt-get is the package manager for Ubuntu and other Debian-based distros,
apk for Alpine
for my base image type linux/amd64(https://hub.docker.com/r/testcafe/testcafe/tags?page=1&ordering=last_updated)
ERROR [2/5] RUN apk update && apk add --no-cache
ERROR [2/5] RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && sudo dpkg -i google-chrome-stable_current_amd64.deb
Was trying like below in docker file:(Not sure exact preprequisites section & install Chrome section)
#Step 0: Choose base
FROM testcafe/testcafe
#Step 1 : Install the pre-requisite
RUN apk update
RUN apt-get install -y curl
RUN apt-get install -y p7zip
p7zip-full
unace
zip
unzip
bzip2
#Version numbers
ARG CHROME_VERSION=89.0.4389.114
#Step 2: Install Chrome
RUN curl http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_$CHROME_VERSION-1_amd64.deb -o /chrome.deb
RUN dpkg -i /chrome.deb
RUN rm /chrome.deb
CMD ["echo", " hello, Welcome to Kiran's custom testcafe docker image!"]
Appreciate if anyone suggest commands in docker file for this object.
Unfortunately, there seems to be no reliable way to install Google Chrome on Alpine Linux. The dpkg package used in your example is intended for Debian-based distributions. While it is available on Alpine Linux as well, it is usually good for lightweight packages only. With heavy packages, it is likely to fail because some of its dependencies are unavailable on Alpine.
That is why the apk package manager is preferred for Alpine Linux. However, google-chrome is not available for apk (only chromium is). See https://stackoverflow.com/a/58781506.
If you need to use a full-featured google-chrome for testing, please consider using a Debian-based Docker image instead of the Alpine-based TestCafe image.
I need to install Sdkman in an Alpine based docker image, but there is a problem that default shell is not Bash. Then command:
source "$HOME/.sdkman/bin/sdkman-init.sh"
ends with failure:
/bin/sh: /root/.sdkman/bin/sdkman-init.sh: line 40: SDKMAN_PLATFORM+=64: not found
You'll need to split the install of SDKMAN and running the init script into two RUN blocks e.g.
RUN apk add bash curl git zip && \
curl -s "https://get.sdkman.io" | bash
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && sdk version"
Source: https://e.printstacktrace.blog/using-sdkman-as-a-docker-image-for-jenkins-pipeline-a-step-by-step-guide/
i have a running docker container, the image its derived from does not have the vnc configured.
I want to configure the vnc on this container and want to access it from my window machine. Is it possible.
I have already gone through so many links but no one really have the details. I do not want to use the images from docker hub since i am creating my own docker image. But i am stuck with vnc as don't know how to proceed with that. Before configuring the vnc in docker file, i want to check it on a running container.
If someone can describe the steps to run the vnc on running container and way to access it from my local window machine using vnc viewer , that will be awesome.
Docker File:
FROM centos:7
RUN yum -y install java
# Install latest version of chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm && yum -y install google-chrome-stable_current_x86_64.rpm
#Install chrome driver 2.40.565383
RUN mkdir /Check/Testfolder/gecko && sudo -S wget https://chromedriver.storage.googleapis.com/2.40/chromedriver_linux64.zip -O /Check/Testfolder/gecko/chromedriver_linux64.zip
RUN unzip /Check/Testfolder/gecko/chromedriver_linux64.zip -d /usr/bin/
#Set XVFB for browser display
RUN yum -y install Xvfb
ENV DISPLAY :99
RUN Xvfb :99 -screen 1200x1080x24 &> /dev/null &
#Install maven
RUN yum -y install maven
I am attempting to build a simple app with Jenkins in a docker container. I have the following Dockerfile:
FROM ubuntu:trusty
# Install dependencies for Flask app.
RUN sudo apt-get update
RUN sudo apt-get install -y vim
RUN sudo apt-get install -y curl
RUN sudo apt-get install -y python3-pip
RUN pip3 install flask
# Install dependencies for Jenkins (Java).
# Install Java 1.8.
RUN sudo apt-get install -y python-software-properties debconf-utils
RUN sudo apt-get install -y software-properties-common
RUN sudo add-apt-repository -y ppa:webupd8team/java
RUN sudo apt-get update
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
RUN sudo apt-get install -y oracle-java8-installer
# Install, start Jenkins.
RUN sudo apt-get install -y wget
RUN wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | apt-key add -
RUN echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
RUN sudo apt-get update
RUN sudo apt-get install -y jenkins
RUN sudo /etc/init.d/jenkins start
COPY ./app /app
CMD ["python3","/app/main.py"]
I run this container with the following:
docker build -t jenkins_test .
docker run --name jenkins_test_container -tid -p 5000:5000 -p 8080:8080 jenkins_test:latest
I am able to start flask and install Jenkins, however, when running, Jenkins is not running. curl localhost:8080 is not successful.
In the log output, I am able to see:
Correct java version found
* Starting Jenkins Automation Server jenkins [ OK ]
However, it's still not running.
I can ssh into the container and manually run sudo /etc/init.d/jenkins start to start it, but I want it to start on docker run or docker build.
I have also tried putting sudo /etc/init.d/jenkins start in the CMD portion of the Docker file:
CMD python3 /app/main.py; sudo /etc/init.d/jenkins start
With this, I am able to curl Flask, but still not Jenkins.
How can I get Jenkins to start automatically?
You have some points that you need to be aware of:
No need to use sudo as the default user is root already.
In order to run multiple service in the same container you need to use any kind of service manager like Supervisord. Jenkins is not running because the CMD is the main entry point for your container so only flask should be running. Check the following link in order to know how to start multiple service in docker.
RUN will be executed only during the build process unlike CMD which will be executed each time you start a container from that image.
Combine all the RUN lines together as possible in order to minimize the build layers which lead to a smaller docker image.
Regarding the usage of this:
CMD python3 /app/main.py; sudo /etc/init.d/jenkins start
It does not work for you because this command python3 /app/main.py is not running as a background process so this command sudo /etc/init.d/jenkins start wont run until the previous command is done.
I was only able to get this to work by starting Jenkins in the CMD portion, but needed to start Jenkins before Flask since Flask would continuously run and the next command would never execute:
Did not work:
CMD python3 /app/main.py; sudo /etc/init.d/jenkins start
This did work:
CMD sudo /etc/init.d/jenkins start; python3 /app/main.py
EDIT:
I believe putting it in the RUN portion would not work because container would build but not save the any running services. I'm not sure if containers can be saved and loaded with running processes like that but I might be wrong. Would appreciate clarification if so.
It seems like a thing that should be in RUN so if anyone knows why that didn't work or some best practices, would also appreciate the info.