Show List

Install Maven on Docker Container

Maven is one of the popular tool Jenkins works with for the application build. In order to run the Maven command from the Jenkins, we need to have Maven installed on the container.

To install Maven on a docker container first get the list of running containers using below command:

docker container ls
C:\Users\mail2>docker container ls
CONTAINER ID   IMAGE                       COMMAND                  CREATED         STATUS         PORTS                 NAMES
20785c1316e6   jenkins/jenkins:lts-jdk11   "/usr/bin/tini -- /u…"   6 seconds ago   Up 5 seconds   8080/tcp, 50000/tcp   objective_cartwright
Now to run the below command to access the container terminal

docker exec -it -u root 20785c1316e6 /bin/bash
C:\Users\mail2>docker exec -it -u root 20785c1316e6 /bin/bash
root@20785c1316e6:/#
Now run command "apt-get update" to update image and then "apt-get install maven"
root@20785c1316e6:/# apt-get update
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8184 kB]
Get:5 https://packagecloud.io/github/git-lfs/debian bullseye InRelease [24.4 kB]
Get:6 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [193 kB]
Get:7 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [14.6 kB]
Get:8 https://packagecloud.io/github/git-lfs/debian bullseye/main amd64 Packages [1728 B]
Fetched 8626 kB in 2s (3601 kB/s)
Reading package lists... Done
root@20785c1316e6:/# apt-get install maven
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  alsa-topology-conf alsa-ucm-conf ca-certificates-java dbus default-jre-headless java-common libaopalliance-java
  libapache-pom-java libapparmor1 libasound2 libasound2-data libatinject-jsr330-api-java libavahi-client3
  libavahi-common-data libavahi-common3 libcdi-api-java libcommons-cli-java libcommons-io-java libcommons-lang3-java
  libcommons-parent-java libcups2 libdbus-1-3 libgeronimo-annotation-1.3-spec-java
  libgeronimo-interceptor-3.0-spec-java libglib2.0-0 libglib2.0-data libgraphite2-3 libguava-java libguice-java
  libharfbuzz0b libhawtjni-runtime-java libicu67 libjansi-java libjansi-native-java libjpeg62-turbo libjsr305-java
  liblcms2-2 libmaven-parent-java libmaven-resolver-java libmaven-shared-utils-java libmaven3-core-java libnspr4
  libnss3 libpcsclite1 libplexus-cipher-java libplexus-classworlds-java libplexus-component-annotations-java
  libplexus-interpolation-java libplexus-sec-dispatcher-java libplexus-utils2-java libsisu-inject-java
  libsisu-plexus-java libslf4j-java libwagon-file-java libwagon-http-shaded-java libwagon-provider-api-java libxml2
  openjdk-11-jre-headless shared-mime-info xdg-user-dirs
Suggested packages:
  default-dbus-session-bus | dbus-session-bus default-jre libaopalliance-java-doc libasound2-plugins alsa-utils
  libatinject-jsr330-api-java-doc libel-api-java libcommons-io-java-doc libcommons-lang3-java-doc cups-common
  libasm-java libcglib-java libjsr305-java-doc liblcms2-utils libmaven-shared-utils-java-doc liblogback-java pcscd
  libplexus-classworlds-java-doc libplexus-sec-dispatcher-java-doc libplexus-utils2-java-doc junit4 testng
  libcommons-logging-java liblog4j1.2-java libnss-mdns fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho
  fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  alsa-topology-conf alsa-ucm-conf ca-certificates-java dbus default-jre-headless java-common libaopalliance-java
  libapache-pom-java libapparmor1 libasound2 libasound2-data libatinject-jsr330-api-java libavahi-client3
  libavahi-common-data libavahi-common3 libcdi-api-java libcommons-cli-java libcommons-io-java libcommons-lang3-java
  libcommons-parent-java libcups2 libdbus-1-3 libgeronimo-annotation-1.3-spec-java
  libgeronimo-interceptor-3.0-spec-java libglib2.0-0 libglib2.0-data libgraphite2-3 libguava-java libguice-java
  libharfbuzz0b libhawtjni-runtime-java libicu67 libjansi-java libjansi-native-java libjpeg62-turbo libjsr305-java
  liblcms2-2 libmaven-parent-java libmaven-resolver-java libmaven-shared-utils-java libmaven3-core-java libnspr4
  libnss3 libpcsclite1 libplexus-cipher-java libplexus-classworlds-java libplexus-component-annotations-java
  libplexus-interpolation-java libplexus-sec-dispatcher-java libplexus-utils2-java libsisu-inject-java
  libsisu-plexus-java libslf4j-java libwagon-file-java libwagon-http-shaded-java libwagon-provider-api-java libxml2
  maven openjdk-11-jre-headless shared-mime-info xdg-user-dirs
0 upgraded, 61 newly installed, 0 to remove and 5 not upgraded.
Need to get 65.2 MB of archives.
After this operation, 252 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
done.
Processing triggers for libc-bin (2.31-13+deb11u4) ...
Processing triggers for ca-certificates (20210119) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
root@20785c1316e6:/#

    Leave a Comment


  • captcha text