Skip Navigation
Resources Blog Sonatype Nexus Repository now supports APT

Sonatype Nexus Repository now supports APT

Beginning with version 3.17, Sonatype Nexus Repository supports Advanced Package Tool (APT) repositories. APT is a set of tools used to search, install, and manage packages on Debian, Ubuntu, and similar Linux distributions.

With this new release, you can now host your own local APT repositories. Developers benefit from no longer having to rely on connecting externally to a public repository every time an often-used package is needed.

In the case of Debian-based Docker containers, the ability to locally cache Debian packages from public repositories can save copious amounts of time when rebuilding your containers. This can do wonders especially for containers built frequently in a CI pipeline and for the more traditional use-case of provisioning virtual machines.

In this simple bare-bones Dockerfile, we download the latest Ubuntu image and run it:

FROM ubuntu:latest
RUN apt-get update && apt-get -y dist-upgrade

The Ubuntu image is pulling the APT packages from the repository listed in our sources.list file which, in this case, points to the public Ubuntu repository. For more benefits of caching your necessary build components, you can use Sonatype Nexus Repository as a local Docker registry.

It's a waste of time to go out to the internet to download a large OS package. Imagine the time being spent on Docker jobs where each build relies on reaching out externally to download a large OS image.

Why worry about the nature of network issues (latency, bandwidth, connectivity, etc.) when you can avoid all of that and store these OS packages locally in Sonatype Nexus Repository? If a developer or build has already downloaded the needed package from the public repository, all can subsequently rely on the package cache within their organization's network.

As our research shows, companies are adopting better DevOps practices and techniques, such as using repositories and packaging applications in containers, to reap the benefits of faster building and provisioning. With 3.17, this is now possible. All you need to do is create a proxy APT repository in Sonatype Nexus Repository which points to the public repository.

Then have your /etc/apt/sources.list file point to your Sonatype Nexus Repository instance.

deb http://admin:admin123@localhost:8081/repository/apt-proxy-updates/ bionic-updates main

Your new Dockerfile should look something like this:

$ apt-get update && apt-get -y dist-upgrade

Get:1 http://localhost:8081/repository/apt-proxy-updates bionic-updates InRelease [88.7 kB]

Get:2 http://localhost:8081/repository/apt-proxy bionic InRelease [242 kB]

Get:3 http://localhost:8081/repository/apt-proxy-updates bionic-updates/main amd64 Packages [881 kB]

Get:4 http://localhost:8081/repository/apt-proxy bionic/main amd64 Packages [1344 kB]

Fetched 2556 kB in 3s (928 kB/s)

More detailed instructions on how to create your APT repositories can be found in our technical documentation.


Picture of Sable Yemane

Written by Sable Yemane

Sable Yemane is a Sales Engineer at Sonatype focused on providing DevSecOps solutions to enterprises